From: Harishankar Date: Tue, 6 Dec 2011 05:45:33 +0000 (+0530) Subject: File Exit and window closing event handled X-Git-Url: https://harishankar.org/repos/?p=biacv.git;a=commitdiff_plain;h=8efe104e153bb6030c7c39dd8c70e05fc23e0a1e File Exit and window closing event handled Implemented handler for menu action File -> Exit and window closing. --- 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 diff --git a/biacv_mainwindow.ui b/biacv_mainwindow.ui index 9be86cd..37d6511 100644 --- a/biacv_mainwindow.ui +++ b/biacv_mainwindow.ui @@ -1025,8 +1025,8 @@ on_add_education() - 70 - 98 + 426 + 189 730 @@ -1041,8 +1041,8 @@ on_delete_education() - 100 - 98 + 658 + 189 728 @@ -1058,7 +1058,7 @@ 100 - 102 + 217 726 @@ -1073,8 +1073,8 @@ on_update_education() - 85 - 98 + 579 + 189 728 @@ -1090,7 +1090,7 @@ 100 - 102 + 217 729 @@ -1105,8 +1105,8 @@ on_change_currentemployment() - 80 - 88 + 328 + 136 728 @@ -1121,8 +1121,8 @@ on_add_profession() - 61 - 99 + 309 + 216 729 @@ -1138,7 +1138,7 @@ 99 - 103 + 244 727 @@ -1154,7 +1154,7 @@ 99 - 103 + 244 729 @@ -1169,8 +1169,8 @@ on_delete_profession() - 99 - 99 + 596 + 216 729 @@ -1185,8 +1185,8 @@ on_update_profession() - 80 - 99 + 453 + 216 726 @@ -1201,8 +1201,8 @@ on_add_skill() - 51 - 96 + 207 + 234 730 @@ -1217,8 +1217,8 @@ on_delete_skill() - 99 - 96 + 566 + 234 728 @@ -1234,7 +1234,7 @@ 99 - 102 + 261 730 @@ -1250,7 +1250,7 @@ 99 - 102 + 261 726 @@ -1265,8 +1265,8 @@ on_update_skill() - 75 - 96 + 386 + 234 728 @@ -1281,8 +1281,8 @@ on_add_lang() - 107 - 110 + 547 + 155 729 @@ -1297,8 +1297,8 @@ on_delete_lang() - 107 - 110 + 716 + 155 733 @@ -1313,8 +1313,8 @@ on_select_lang() - 98 - 110 + 103 + 189 730 @@ -1329,8 +1329,8 @@ on_select_lang() - 98 - 110 + 103 + 189 730 @@ -1345,8 +1345,8 @@ on_update_lang() - 107 - 110 + 644 + 155 729 @@ -1361,7 +1361,7 @@ on_document_modified() - 480 + 182 41 @@ -1426,7 +1426,7 @@ 223 - 186 + 174 538 @@ -1442,7 +1442,7 @@ 170 - 265 + 245 196 @@ -1458,7 +1458,7 @@ 437 - 268 + 248 88 @@ -1474,7 +1474,7 @@ 527 - 264 + 244 165 @@ -1490,7 +1490,7 @@ 204 - 305 + 281 -1 @@ -1506,7 +1506,7 @@ 409 - 309 + 285 575 @@ -1522,7 +1522,7 @@ 588 - 305 + 281 0 @@ -1538,7 +1538,7 @@ 93 - 356 + 328 -3 @@ -1554,7 +1554,7 @@ 372 - 351 + 323 2 @@ -1570,7 +1570,7 @@ 118 - 396 + 364 0 @@ -1586,7 +1586,7 @@ 149 - 436 + 400 1 @@ -1602,7 +1602,7 @@ 212 - 431 + 395 3 @@ -1618,7 +1618,7 @@ 303 - 436 + 400 -2 @@ -1634,7 +1634,7 @@ 99 - 89 + 101 0 @@ -1650,7 +1650,7 @@ 90 - 102 + 297 2 @@ -1666,7 +1666,7 @@ 94 - 103 + 333 1 @@ -1738,6 +1738,22 @@ + + actionE_xit + triggered() + biacv_mainwindow + on_exit() + + + -1 + -1 + + + 364 + 248 + + + on_add_education() @@ -1762,5 +1778,6 @@ on_file_save() on_file_open() on_file_save_as() + on_exit() diff --git a/biacv_mainwindow_ui.py b/biacv_mainwindow_ui.py index 504b102..35ef21f 100644 --- a/biacv_mainwindow_ui.py +++ b/biacv_mainwindow_ui.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'biacv_mainwindow.ui' # -# Created: Tue Dec 6 10:37:09 2011 +# Created: Tue Dec 6 11:15:27 2011 # by: PyQt4 UI code generator 4.8.6 # # WARNING! All changes made in this file will be lost! @@ -610,6 +610,7 @@ class Ui_biacv_mainwindow(object): QtCore.QObject.connect(self.action_Save, QtCore.SIGNAL(_fromUtf8("triggered()")), biacv_mainwindow.on_file_save) QtCore.QObject.connect(self.action_Open, QtCore.SIGNAL(_fromUtf8("triggered()")), biacv_mainwindow.on_file_open) QtCore.QObject.connect(self.actionSave_As, QtCore.SIGNAL(_fromUtf8("triggered()")), biacv_mainwindow.on_file_save_as) + QtCore.QObject.connect(self.actionE_xit, QtCore.SIGNAL(_fromUtf8("triggered()")), biacv_mainwindow.on_exit) QtCore.QMetaObject.connectSlotsByName(biacv_mainwindow) def retranslateUi(self, biacv_mainwindow):