Browse Source

Make exit button work

tb-init-ui-render
Taylor Bockman 5 years ago
parent
commit
a93693d925
  1. 4
      clusterview.ui
  2. 8
      clusterview_ui.py
  3. 8
      main_window.py

4
clusterview.ui

@ -197,7 +197,7 @@
<addaction name="action_load_point_configuration"/> <addaction name="action_load_point_configuration"/>
<addaction name="action_save_point_configuration"/> <addaction name="action_save_point_configuration"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionExit"/> <addaction name="action_exit"/>
</widget> </widget>
<widget class="QMenu" name="menu_help"> <widget class="QMenu" name="menu_help">
<property name="title"> <property name="title">
@ -290,7 +290,7 @@
<string>Load Point Configuration</string> <string>Load Point Configuration</string>
</property> </property>
</action> </action>
<action name="actionExit"> <action name="action_exit">
<property name="text"> <property name="text">
<string>Exit</string> <string>Exit</string>
</property> </property>

8
clusterview_ui.py

@ -113,14 +113,14 @@ class Ui_MainWindow(object):
self.action_save_point_configuration.setObjectName("action_save_point_configuration") self.action_save_point_configuration.setObjectName("action_save_point_configuration")
self.action_load_point_configuration = QtWidgets.QAction(MainWindow) self.action_load_point_configuration = QtWidgets.QAction(MainWindow)
self.action_load_point_configuration.setObjectName("action_load_point_configuration") self.action_load_point_configuration.setObjectName("action_load_point_configuration")
self.actionExit = QtWidgets.QAction(MainWindow) self.action_exit = QtWidgets.QAction(MainWindow)
self.actionExit.setObjectName("actionExit") self.action_exit.setObjectName("action_exit")
self.action_generate_random_points = QtWidgets.QAction(MainWindow) self.action_generate_random_points = QtWidgets.QAction(MainWindow)
self.action_generate_random_points.setObjectName("action_generate_random_points") self.action_generate_random_points.setObjectName("action_generate_random_points")
self.menu_file.addAction(self.action_load_point_configuration) self.menu_file.addAction(self.action_load_point_configuration)
self.menu_file.addAction(self.action_save_point_configuration) self.menu_file.addAction(self.action_save_point_configuration)
self.menu_file.addSeparator() self.menu_file.addSeparator()
self.menu_file.addAction(self.actionExit) self.menu_file.addAction(self.action_exit)
self.menubar.addAction(self.menu_file.menuAction()) self.menubar.addAction(self.menu_file.menuAction())
self.menubar.addAction(self.menu_help.menuAction()) self.menubar.addAction(self.menu_help.menuAction())
self.tool_bar.addAction(self.action_generate_random_points) self.tool_bar.addAction(self.action_generate_random_points)
@ -158,5 +158,5 @@ class Ui_MainWindow(object):
self.action_move_points.setToolTip(_translate("MainWindow", "Enables the movement of a selection of points.")) self.action_move_points.setToolTip(_translate("MainWindow", "Enables the movement of a selection of points."))
self.action_save_point_configuration.setText(_translate("MainWindow", "Save Point Configuration")) self.action_save_point_configuration.setText(_translate("MainWindow", "Save Point Configuration"))
self.action_load_point_configuration.setText(_translate("MainWindow", "Load Point Configuration")) self.action_load_point_configuration.setText(_translate("MainWindow", "Load Point Configuration"))
self.actionExit.setText(_translate("MainWindow", "Exit")) self.action_exit.setText(_translate("MainWindow", "Exit"))
self.action_generate_random_points.setText(_translate("MainWindow", "Generate Random Points")) self.action_generate_random_points.setText(_translate("MainWindow", "Generate Random Points"))

8
main_window.py

@ -25,6 +25,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
`clusterview.ui`. `clusterview.ui`.
""" """
# This is a static mode variable since there will only ever
# be one MainWindow.
__mode = Mode.OFF __mode = Mode.OFF
def __init__(self, parent=None): def __init__(self, parent=None):
@ -78,6 +80,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.action_load_point_configuration.triggered.connect( self.action_load_point_configuration.triggered.connect(
self.__open_points_file) self.__open_points_file)
self.action_exit.triggered.connect(self.__close_event)
# Override handler for mouse press so we can draw points based on # Override handler for mouse press so we can draw points based on
# the OpenGL coordinate system inside of the OpenGL Widget. # the OpenGL coordinate system inside of the OpenGL Widget.
self.opengl_widget.mousePressEvent = self.__ogl_click_dispatcher self.opengl_widget.mousePressEvent = self.__ogl_click_dispatcher
@ -139,6 +143,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def mode(self, mode): def mode(self, mode):
self.__mode = mode self.__mode = mode
def __close_event(self, event):
import sys
sys.exit(0)
def __open_points_file(self): def __open_points_file(self):
ofile, _ = QFileDialog.getOpenFileName(self, ofile, _ = QFileDialog.getOpenFileName(self,
"Open Point Configuration", "Open Point Configuration",

Loading…
Cancel
Save