Skip to content

Commit

Permalink
save project when close TagLab main window
Browse files Browse the repository at this point in the history
  • Loading branch information
gaiapavoni committed Nov 5, 2021
1 parent d078fb1 commit 483ee40
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions TagLab.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@
logging.basicConfig(level=logging.DEBUG, filemode='w', filename=LOG_FILENAME, format = '%(asctime)s %(levelname)-8s %(message)s')
logfile = logging.getLogger("tool-logger")

class MainWindow(QMainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
pass
def closeEvent(self, event):
taglab = self.centralWidget()
if taglab.project.filename is not None:
box = QMessageBox()
reply = box.question(self, taglab.TAGLAB_VERSION, "Do you want to save changes to" + taglab.project.filename, QMessageBox.Yes | QMessageBox.No)
if reply == QMessageBox.Yes:
taglab.saveProject()
super(MainWindow, self).closeEvent(event)

class TagLab(QMainWindow):

def __init__(self, parent=None):
Expand Down Expand Up @@ -3932,9 +3945,8 @@ def applyClassifier(self):

# Create the inspection tool
tool = TagLab()

# create the main window - TagLab widget is the central widget
mw = QMainWindow()
mw = MainWindow()
title = tool.TAGLAB_VERSION
mw.setWindowTitle(title)
mw.setCentralWidget(tool)
Expand All @@ -3943,4 +3955,5 @@ def applyClassifier(self):

# Show the viewer and run the application.
mw.show()

sys.exit(app.exec_())

0 comments on commit 483ee40

Please sign in to comment.