[Pythonmac-SIG] Some question about pyobjc and creating nib based application...

Bob Ippolito bob at redivi.com
Tue Jan 4 19:33:33 CET 2005


On Jan 4, 2005, at 1:20 PM, whamoo wrote:

> Hello,
>
> There's somethings i cannot understand about creating nib based  
> application,
> Ok I start interface builder, build gui, create outlet, create action,  
> saving, create python file starting by the nib, and having a thing  
> like this:
>
> ----------------------------------------------
>
> import objc
> from Foundation import *
> from AppKit import *
> from PyObjCTools import NibClassBuilder, AppHelper
>
>
> NibClassBuilder.extractClasses("MainMenu")
>
>
> # class defined in gino.nib
> class finestra(NibClassBuilder.AutoBaseClass):
>     # the actual base class is NSObject
>     # The following outlets are added to the class:
>     # button
>     # label
>
>     def change_(self, sender):
>         self.label.setStringValue_("Prova")
>
>
>
> if __name__ == "__main__":
>     AppHelper.runEventLoop()
>
> ----------------------------------------------
>
> Ok, finestra is the base class and all works, but why is the base  
> class? if i create more class??

BTW:  You should name your classes LikeThis, it is both Python and  
Objective-C convention.

finestra is not "the base class".  When you use  
NibClassBuilder.AutoBaseClass, you are saying "ask the nib what my base  
class is".  For more information, see  
<http://pyobjc.sourceforge.net/doc/pyobjctools.php#pyobjctools- 
nibclassbuilder>

> I've tried xcode template, but if I modify the AppDelegate nib and add  
> the function in python file, it give me this error:
>
> Could not connect the action change_: to target of class provaDocument

Did you actually write "change_:" as the selector?  That's not how it  
works.  Underscores are used from Python and colons are used from  
Objective-C.  Maybe you should read  
<http://pyobjc.sourceforge.net/doc/intro.php>.  The selector should be  
named "change:" in this case.  Also, your source example does not  
define any class named "provaDocument".

> And i don't know why =P

Did you read the documentation? I spent a lot of time on it before the  
1.2 release ;)

> I need to know what is the base class, i can chose? There's somethings  
> that I probably miss, someone can help?

Hopefully this question will be answered by the referenced  
documentation...

-bob



More information about the Pythonmac-SIG mailing list