Browse Source

Get clusterview running on UI file generated code

tb-init-ui-render
Taylor Bockman 5 years ago
parent
commit
4c7a5604f7
  1. 15
      CONTRIBUTING.md
  2. 2
      clusterview.py
  3. 81
      clusterview_ui.py
  4. 26
      main_window.py

15
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_file>.ui -o <python_file>.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

2
clusterview.py

@ -10,6 +10,8 @@ def main():
window = MainWindow()
window.show()
sys.exit(app.exec_())

81
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"))

26
main_window.py

@ -2,25 +2,15 @@ import os
from PyQt5 import QtWidgets, uic
class MainWindow(QtWidgets.QMainWindow):
"""
A wrapper class for handling creating a window based
on a Qt Designer *.ui file.
"""
# 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__))
from clusterview_ui import Ui_MainWindow
__UI_FILE_NAME = "clusterview.ui"
def __init__(self):
class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
"""
Initializes and launches the UI in one shot.
A wrapper class for handling creating a window based
on the `clusterview_ui.py` code generated from
`clusterview.ui`.
"""
# 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)

Loading…
Cancel
Save