From: Alex T. <al...@tw...> - 2005-12-18 02:00:27
|
Don Taylor wrote: > I think that there is also a problem in this bit of code on the last > page of the "How to add a child window" walkthrough: > > def doExit(self): > self.parent.components.field1.text = "99" > > def on_close(self, event): > self.doExit() > self.visible = False > > def on_menuFileExit_select(self, event): > self.close() > > The on_menuFileExit_select event does not seem to get fired anymore so > the code and the description need to be changed. > You're right, the doc should be changed (see below) > Don. > > PS. Is it simply not possible to intercept File->Exit events now, or > is there some other event that can be used instead? > It is possible to intercept File->Exit, just as before. The reason it's not being fired in the child window walkthrough, is that the "Counter" example being used is derived from the Minimal sample - and "minimal" now uses a "command" for its menus. (In minimal.rsrc.py, you'll see > > 'menubar': > { > 'type':'MenuBar', > 'menus': > [ > { 'type':'Menu', > 'name':'menuFile', > 'label':'&File', > 'items': [ > { 'type':'MenuItem', > 'name':'menuFileExit', > 'label':'E&xit\tAlt+X', > 'command':'exit' } ] } > ] > }, Because the File/Exit entry has a command defined, it triggers that instead of the menu select event. So the code fragment should be changed from > def on_menuFileExit_select(self, event): > self.close() to > def on_exit_command(self, event): > self.close() (and enough explanatory text should be added to explain this ....) -- Alex Tweedly http://www.tweedly.net -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.371 / Virus Database: 267.14.1/206 - Release Date: 16/12/2005 |