Skip to content

Commit

Permalink
Override inherited closeEvent function to minimize widget instead of …
Browse files Browse the repository at this point in the history
…closing.
  • Loading branch information
samivout committed Dec 6, 2023
1 parent 2b3a25d commit edda6c4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions widgets/measurement/tofe_histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,14 @@ def __set_shortcuts(self):
self.__paste_selection = QtWidgets.QShortcut(QKeySequence(QtCore.Qt.CTRL+QtCore.Qt.Key_V), self)
self.__paste_selection.activated.connect(self.matplotlib.paste_selection)

def closeEvent(self, close_event):
"""Event which happens when the windows is closing.
Instead of closing, minimize the window. Fixes close buttons on macOS,
which for the time being cannot be disabled.
Args:
close_event: Close event
"""
close_event.ignore()
self.showMinimized()

11 changes: 11 additions & 0 deletions widgets/simulation/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,3 +247,14 @@ def set_shortcuts(self):
self.del_points.setKey(QtCore.Qt.Key_Delete)
self.del_points.activated.connect(
lambda: self.recoil_distribution_widget.remove_points())

def closeEvent(self, close_event):
"""Event which happens when the windows is closing.
Instead of closing, minimize the window. Fixes close buttons on macOS,
which for the time being cannot be disabled.
Args:
close_event: Close event
"""
close_event.ignore()
self.showMinimized()

0 comments on commit edda6c4

Please sign in to comment.