Re: [Pyobjc-dev] NSBeginAlertSheet trouble
Brought to you by:
ronaldoussoren
From: Just v. R. <ju...@le...> - 2003-06-19 07:03:47
|
Dinu Gherman wrote: > I wrote: > > > Surprisingly that doesn't work for me (on the latest CVS version). > > But using objc.selector() directly does work. I'm attaching the file > > MyAppDelegate.py which you can replace the respective file with from > > the "Cocoa Python Application" PB template to test. > > Also very strange: if I use in the same file these methods which > try to save the return value of the sheet in a variable x for fur- > ther use, I get an AttributeError and the app crashes before I even > have a chance of clicking any button in the sheet itself: > > def sayHelloAction_(self, sender): > # adapted from same method of the "Cocoa Python Application" PB > template > info = 0 > makeAlertSheet("title", "msg", info, sender.window(), self) > print self.x > > def sheetDidEnd_returnCode_contextInfo_(self, sheet, returnCode, > info): > print "sheetDidEnd_returnCode_contextInfo_", sheet, returnCode, > info > self.x = returnCode > > I don't know which other way one can use the returnCode, since the > NSBeginAlertSheet() function itself returns only None... NSBeginAlertSheet() returns _immediately_, and therefor your x attribute will only be available after sheetDidEnd_etc. was called. Sheets are modal to the window, not the entire app, so while the sheet is up there the event loop continues as usual. That's why it uses callbacks instead of a return value... Just |