Thread: [Pyobjc-dev] objc.BadPrototypeError
Brought to you by:
ronaldoussoren
From: Rob <rob...@gm...> - 2009-11-13 06:14:57
|
(Please tell me if this is the wrong list for this kind of thing) I am trying to port an application written against the stock python+pyobjc on Leopard to one on snow leopard, and I've hit and error I can't solve. I have a sheet that pops in that allows one to select files, and it does this: self.panel.beginSheetForDirectory_file_types_modalForWindow_modalDelegate_didEndSelector_contextInfo_( os.getcwd(), None, self.filetypes, NSApp().mainWindow(), self, 'openPanelDidEnd:panel:returnCode:contextInfo:', 0) the key being the 'openPanelDidEnd:panel:returnCode:contextInfo:' part. The signature of that method seems to have changed between Leopard and Snow Leopard, but the decorator in pyobjc doesn't appear updated. I am guess this is what is going on because my method defined as: @PyObjCTools.AppHelper.endSheetMethod def openPanelDidEnd_panel_returnCode_contextInfo_(self, panel, returnCode, contextInfo): (which works fine in Leopard) throws the error: objc.BadPrototypeError: Python signature doesn't match implied Objective-C signature for <unbound selector openPanelDidEnd:panel:returnCode:contextInfo: of desktop_uploaderAppDelegate at 0x2fb6d70> I've tried to figure out how to write the signature myself, but I seem to suck badly at doing so. Nothing I have tried has worked. I've tried (some were just googled, some I tired to write myself by looking at the apple docs): @objc.signature('v@:^@i^v') @objc.signature('v16@4:8@12i16i20') @objc.signature('v@:@i^v') amongst others, but everything I try just throws that objc.BadPrototypeError: and crashes the program. Seems like it should be an easy fix if I could sort out the signature - can anyone help or point me in the right direction? cheers, rob -- http://robrohan.com http://twitter.com/robrohan |
From: Ronald O. <ron...@ma...> - 2009-11-13 13:29:47
|
(mobilme webmail seems to mess up quoting, hence my toppost). The callback method should be named 'openPanelDidEnd:returnCode:contextInfo:', (that is "openPanelDidEnd_returnCode_contextInfo_". The name your using contains 4 underscores, and should therefore have 5 arguments (including 'self'), while the sheet expects a method with 3 arguments. Ronald On Friday, November 13, 2009, at 07:14AM, "Rob" <rob...@gm...> wrote: >------------------------------------------------------------------------------ >Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day >trial. Simplify your report design, integration and deployment - and focus on >what you do best, core application coding. Discover what's new with >Crystal Reports now. http://p.sf.net/sfu/bobj-july >_______________________________________________ >Pyobjc-dev mailing list >Pyo...@li... >https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > |
From: Rob <rob...@gm...> - 2009-11-15 23:24:08
|
It took me a few minutes to get what you were saying, but you are right. Your comment did get me sorted. The code I initially used was listed on numerous blogs as an example of how to do the sheet, so just so others searching on this find a conclusive answer: This method signature is correct: @PyObjCTools.AppHelper.endSheetMethod def openPanelDidEnd_returnCode_contextInfo_(self, panel, returnCode, contextInfo): However "hooking up the callback" (or whatever the proper term is) like this: 'openPanelDidEnd:panel:returnCode:contextInfo:' is incorrect, because there are too many parameters. Setting up the callback with 4 parameters works in Leopard, but it does not in Snow Leopard for some reason (probably because it's wrong). Using the call back of: 'openPanelDidEnd:returnCode:contextInfo:' Makes joy. And to do some ascii art to solidify what Ronald was saying 'openPanelDidEnd:returnCode:contextInfo:' ^ ^ ^ 1 2 3 openPanelDidEnd_returnCode_contextInfo_(self, panel, returnCode, contextInfo): ^ ^ ^ 1 2 3 Thanks again Ronald rob On Fri, Nov 13, 2009 at 11:28 PM, Ronald Oussoren <ron...@ma...>wrote: > (mobilme webmail seems to mess up quoting, hence my toppost). > > The callback method should be named 'openPanelDidEnd:returnCode:contextInfo:', (that is "openPanelDidEnd_returnCode_contextInfo_". The name your using contains 4 underscores, and should therefore have 5 arguments (including 'self'), while the sheet expects a method with 3 arguments. > > Ronald > > On Friday, November 13, 2009, at 07:14AM, "Rob" <rob...@gm...> wrote: > >------------------------------------------------------------------------------ > >Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > >trial. Simplify your report design, integration and deployment - and focus on > >what you do best, core application coding. Discover what's new with > >Crystal Reports now. http://p.sf.net/sfu/bobj-july > >_______________________________________________ > >Pyobjc-dev mailing list > >Pyo...@li... > >https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > > > > > (Please tell me if this is the wrong list for this kind of thing) > > I am trying to port an application written against the stock python+pyobjc > on Leopard to one on snow leopard, and I've hit and error I can't solve. I > have a sheet that pops in that allows one to select files, and it does this: > > > self.panel.beginSheetForDirectory_file_types_modalForWindow_modalDelegate_didEndSelector_contextInfo_( > os.getcwd(), > None, > self.filetypes, > NSApp().mainWindow(), > self, > 'openPanelDidEnd:panel:returnCode:contextInfo:', > 0) > > the key being the 'openPanelDidEnd:panel:returnCode:contextInfo:' part. > > The signature of that method seems to have changed between Leopard and > Snow Leopard, but the decorator in pyobjc doesn't appear updated. I am > guess this is what is going on because my method defined as: > > @PyObjCTools.AppHelper.endSheetMethod > def openPanelDidEnd_panel_returnCode_contextInfo_(self, panel, returnCode, > contextInfo): > > (which works fine in Leopard) throws the error: > > objc.BadPrototypeError: Python signature doesn't match implied > Objective-C signature for <unbound selector > openPanelDidEnd:panel:returnCode:contextInfo: of desktop_uploaderAppDelegate > at 0x2fb6d70> > > I've tried to figure out how to write the signature myself, but I seem to > suck badly at doing so. Nothing I have tried has worked. I've tried (some > were just googled, some I tired to write myself by looking at the apple > docs): > > @objc.signature('v@:^@i^v') > @objc.signature('v16@4:8@12i16i20') > @objc.signature('v@:@i^v') > > amongst others, but everything I try just throws > that objc.BadPrototypeError: and crashes the program. > > Seems like it should be an easy fix if I could sort out the signature - > can anyone help or point me in the right direction? > > cheers, > rob > > -- > http://robrohan.com > http://twitter.com/robrohan > -- http://robrohan.com http://twitter.com/robrohan |