On 29/02/16 16:22, CMG Thrissur wrote:
> This below given code is giving a race condition, i.e. sometimes gives 
> the result as expected, sometimes gives error, sometimes just does 
> nothing. 

Don't use the __del__ method for that kind of code, put it in
the close event handler. You don't know when the del() will be
called or what state your dialog object and data will be in.

> 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()


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to