[Tutor] pyqt __del__ race conditions in subclassed form
CMG Thrissur
cmgcomsol at gmail.com
Mon Feb 29 11:22:49 EST 2016
Hello,
This below given code is giving a race condition, i.e. sometimes gives
the result as expected, sometimes gives error, sometimes just does
nothing. It is part of a subclassed qt form which i am using as main
dialog. This behaviour occurs when i close the dialog whereby ending
the application. what i want to achieve is that when the dialog is
closed if any unsaved data, prompt the user.
Thanks
George
___________________________________________________________________________________________________________________________________
def __del__(self):
if self.Saved==False:
choice = PyQt4.QtGui.QMessageBox.question(self,'Warning','Data modified. Do you want to save?',
QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
print(type(choice), choice)
if choice == QMessageBox.Yes:
self.SaveData()
___________________________________________________________________________________________________________________________________
More information about the Tutor
mailing list