From a93693d9259a9891c5fe0289d910881fec891134 Mon Sep 17 00:00:00 2001 From: Taylor Bockman Date: Wed, 21 Aug 2019 17:26:59 -0700 Subject: [PATCH] Make exit button work --- clusterview.ui | 4 ++-- clusterview_ui.py | 8 ++++---- main_window.py | 8 ++++++++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/clusterview.ui b/clusterview.ui index 6f30532..16914ae 100644 --- a/clusterview.ui +++ b/clusterview.ui @@ -197,7 +197,7 @@ - + @@ -290,7 +290,7 @@ Load Point Configuration - + Exit diff --git a/clusterview_ui.py b/clusterview_ui.py index 4e79b69..e37b328 100644 --- a/clusterview_ui.py +++ b/clusterview_ui.py @@ -113,14 +113,14 @@ class Ui_MainWindow(object): self.action_save_point_configuration.setObjectName("action_save_point_configuration") self.action_load_point_configuration = QtWidgets.QAction(MainWindow) self.action_load_point_configuration.setObjectName("action_load_point_configuration") - self.actionExit = QtWidgets.QAction(MainWindow) - self.actionExit.setObjectName("actionExit") + self.action_exit = QtWidgets.QAction(MainWindow) + self.action_exit.setObjectName("action_exit") self.action_generate_random_points = QtWidgets.QAction(MainWindow) 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_save_point_configuration) 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_help.menuAction()) 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_save_point_configuration.setText(_translate("MainWindow", "Save 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")) diff --git a/main_window.py b/main_window.py index faa4ac7..6cb57b1 100644 --- a/main_window.py +++ b/main_window.py @@ -25,6 +25,8 @@ class MainWindow(QMainWindow, Ui_MainWindow): `clusterview.ui`. """ + # This is a static mode variable since there will only ever + # be one MainWindow. __mode = Mode.OFF def __init__(self, parent=None): @@ -78,6 +80,8 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.action_load_point_configuration.triggered.connect( self.__open_points_file) + self.action_exit.triggered.connect(self.__close_event) + # Override handler for mouse press so we can draw points based on # the OpenGL coordinate system inside of the OpenGL Widget. self.opengl_widget.mousePressEvent = self.__ogl_click_dispatcher @@ -139,6 +143,10 @@ class MainWindow(QMainWindow, Ui_MainWindow): def mode(self, mode): self.__mode = mode + def __close_event(self, event): + import sys + sys.exit(0) + def __open_points_file(self): ofile, _ = QFileDialog.getOpenFileName(self, "Open Point Configuration",