X-Git-Url: https://harishankar.org/repos/?p=biacv.git;a=blobdiff_plain;f=biacv_mainwindow.py;fp=biacv_mainwindow.py;h=91599b988242eca09f8e964c44c8769cc45afdc9;hp=681469d52baa28871d8809c05745b2a590abe533;hb=8efe104e153bb6030c7c39dd8c70e05fc23e0a1e;hpb=41ec06537e95d26566994964b79ad50afa232be5 diff --git a/biacv_mainwindow.py b/biacv_mainwindow.py index 681469d..91599b9 100644 --- a/biacv_mainwindow.py +++ b/biacv_mainwindow.py @@ -2,6 +2,8 @@ # class for main window import PyQt4 +import sys + import biacv_mainwindow_ui as bui import biacv_lang as lang import biacv_data as data @@ -14,6 +16,20 @@ class Biacv_mainwindow (PyQt4.QtGui.QMainWindow, bui.Ui_biacv_mainwindow): self.ismodified = False self.setWindowTitle ("BiaCV - untitled") + # on window closing + def closeEvent (self, event): + if self.ismodified is True: + ans = PyQt4.QtGui.QMessageBox.question (self, lang.CONFIRM, lang.CONFIRM_DISCARD_SAVE, + PyQt4.QtGui.QMessageBox.Yes, PyQt4.QtGui.QMessageBox.No) + # ignore event if not confirmed + if ans <> PyQt4.QtGui.QMessageBox.Yes: + event.ignore () + + # on file exit + def on_exit (self): + # call the close event + self.close() + # function to open a file def on_file_open (self): # if modified, confirm