From: <bra...@om...> - 2005-05-22 20:22:03
|
When a window closes, I want to prompted the user to save changes if needed. The script below seems to work fine for that, except for one glitch: if the user edits a field, then clicks the closebox on the window, an on_closefield never gets sent. I'd like to send a closefield event to the widget that has the focus (if it's a field). I've tried using self.components.getFocus, among other things...there must be something obvious I'm missing. Thanks! def on_close (self, event): print 'caught a close window' if hasattr (self, 'entity'): if len (self.entity.newData) > 0: result = self.warningUnsavedChanges() if result.accepted: if result.returnedString == 'No': print "Don't save changes; close window" self.revert() self.visible = False else: #save changes try: self.save() self.visible = False except Exception, thisErr: errMsg = str(thisErr) self.warningGeneral ('Problem saving changes: ' + errMsg) else: pass #do nothing; do not close window else: #nothing to save self.visible = False else: print "this must not be a window with a DbEntity; nothing to save" event.skip() |