diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ba21a73..cc1793e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -32,6 +32,21 @@ We use `pytest` as our testing framework. TODO +## Updating the UI Design File + +In order to load the UI and be able to interact with the various parts you will +need to convert the UI file to a python file. To do so: + +```sh +pyuic5 .ui -o .py +``` + +For example, to be able to use changes you've made to the main UI file: + +``` +pyuic5 clusterview.ui clusterview_ui.py +``` + ## Style ### Import Organization diff --git a/clusterview.py b/clusterview.py index 7a72c40..3b2d5c0 100644 --- a/clusterview.py +++ b/clusterview.py @@ -10,6 +10,8 @@ def main(): window = MainWindow() + window.show() + sys.exit(app.exec_()) diff --git a/clusterview_ui.py b/clusterview_ui.py new file mode 100644 index 0000000..e90e735 --- /dev/null +++ b/clusterview_ui.py @@ -0,0 +1,81 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'clusterview.ui' +# +# Created by: PyQt5 UI code generator 5.13.0 +# +# WARNING! All changes made in this file will be lost! + + +from PyQt5 import QtCore, QtGui, QtWidgets + + +class Ui_MainWindow(object): + def setupUi(self, MainWindow): + MainWindow.setObjectName("MainWindow") + MainWindow.resize(1280, 720) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth()) + MainWindow.setSizePolicy(sizePolicy) + MainWindow.setMinimumSize(QtCore.QSize(1280, 720)) + self.centralwidget = QtWidgets.QWidget(MainWindow) + self.centralwidget.setObjectName("centralwidget") + self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget) + self.verticalLayout.setObjectName("verticalLayout") + self.opengl_widget = QtWidgets.QOpenGLWidget(self.centralwidget) + self.opengl_widget.setObjectName("opengl_widget") + self.verticalLayout.addWidget(self.opengl_widget) + MainWindow.setCentralWidget(self.centralwidget) + self.menubar = QtWidgets.QMenuBar(MainWindow) + self.menubar.setGeometry(QtCore.QRect(0, 0, 1280, 28)) + self.menubar.setNativeMenuBar(True) + self.menubar.setObjectName("menubar") + self.menu_file = QtWidgets.QMenu(self.menubar) + self.menu_file.setObjectName("menu_file") + self.menu_help = QtWidgets.QMenu(self.menubar) + self.menu_help.setObjectName("menu_help") + MainWindow.setMenuBar(self.menubar) + self.status_bar = QtWidgets.QStatusBar(MainWindow) + self.status_bar.setObjectName("status_bar") + MainWindow.setStatusBar(self.status_bar) + self.tool_bar = QtWidgets.QToolBar(MainWindow) + self.tool_bar.setObjectName("tool_bar") + MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.tool_bar) + self.action_add_points = QtWidgets.QAction(MainWindow) + self.action_add_points.setObjectName("action_add_points") + self.action_edit_points = QtWidgets.QAction(MainWindow) + self.action_edit_points.setObjectName("action_edit_points") + self.action_delete_points = QtWidgets.QAction(MainWindow) + self.action_delete_points.setObjectName("action_delete_points") + self.action_solve = QtWidgets.QAction(MainWindow) + self.action_solve.setObjectName("action_solve") + self.menubar.addAction(self.menu_file.menuAction()) + self.menubar.addAction(self.menu_help.menuAction()) + self.tool_bar.addAction(self.action_add_points) + self.tool_bar.addAction(self.action_edit_points) + self.tool_bar.addAction(self.action_delete_points) + self.tool_bar.addAction(self.action_solve) + + self.retranslateUi(MainWindow) + QtCore.QMetaObject.connectSlotsByName(MainWindow) + + def retranslateUi(self, MainWindow): + _translate = QtCore.QCoreApplication.translate + MainWindow.setWindowTitle(_translate("MainWindow", "ClusterView")) + self.menu_file.setTitle(_translate("MainWindow", "File")) + self.menu_help.setTitle(_translate("MainWindow", "Help")) + self.tool_bar.setWindowTitle(_translate("MainWindow", "toolBar")) + self.action_add_points.setText(_translate("MainWindow", "Add Points")) + self.action_add_points.setToolTip(_translate("MainWindow", "Enables point adding mode.")) + self.action_add_points.setShortcut(_translate("MainWindow", "Ctrl+A")) + self.action_edit_points.setText(_translate("MainWindow", "Edit Points")) + self.action_edit_points.setToolTip(_translate("MainWindow", "Enables point editing mode.")) + self.action_edit_points.setShortcut(_translate("MainWindow", "Ctrl+E")) + self.action_delete_points.setText(_translate("MainWindow", "Delete Points")) + self.action_delete_points.setToolTip(_translate("MainWindow", "Enables point deletion mode.")) + self.action_delete_points.setShortcut(_translate("MainWindow", "Ctrl+D")) + self.action_solve.setText(_translate("MainWindow", "Solve")) + self.action_solve.setToolTip(_translate("MainWindow", "Opens the solve dialog to choose a solving solution.")) + self.action_solve.setShortcut(_translate("MainWindow", "Ctrl+S")) diff --git a/main_window.py b/main_window.py index 4ef53e8..c2be41e 100644 --- a/main_window.py +++ b/main_window.py @@ -2,25 +2,15 @@ import os from PyQt5 import QtWidgets, uic -class MainWindow(QtWidgets.QMainWindow): +from clusterview_ui import Ui_MainWindow + +class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): """ A wrapper class for handling creating a window based - on a Qt Designer *.ui file. + on the `clusterview_ui.py` code generated from + `clusterview.ui`. """ - # This file will always live in the root so we can yank - # the root directory from it's location safely. - __ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) - - __UI_FILE_NAME = "clusterview.ui" - - def __init__(self): - """ - Initializes and launches the UI in one shot. - """ - - # Assumption: The UI file will be in the project root. - - super(MainWindow, self).__init__() - uic.loadUi("{}/{}".format(self.__ROOT_DIR,self. __UI_FILE_NAME)) - self.show() + def __init__(self, parent=None): + super(MainWindow, self).__init__(parent) + self.setupUi(self)