I've done a little bit Cocoa programming using Objective-C and tried PyObjc back under Xcode/IB 2.0, but now I'd like to try PyObjc with Xcode/IB 3. Using a mixture of documentation, here's what I've come up with. Can someone please let me know if there's anything wrong with this process or if there is a much easier way (I'm not complaining - this seems pretty simple to me) to create a simple PyObjc app (no bindings, or existing controller classes, etc.) using the Leopard System python/pyobjc (i.e., the python that comes with Leopard).

1. In Xcode 3, create a Cocoa Python Objc Application
2. add a new Python file that will be the controller
3. click on MainMenu.xib to open IB
4. create interface
5. drag a NSObject to IB MainMenu.xib window (I believe this is referred to as the Doc window)
5. in the IB Inspector window do the following
5.1 change the Class Identity to the Python controller class I just created 5.2 add outlets for the widgets I need to access in the Class Outlets section 5.3 add actions (no underscores in names, end in a colon) in the Class Actions section 6. Control mouse drag from Controller in Doc Window to each widget and set the outlet 7. Control mouse drag from Buttons, etc. to the Controller and set the action
8. in Controller Python file:
8.1 add a line for each outlet right under class definition that looks like: outletName = objc.IBOutlet() (this will allow methods to access the outlet as self.outletName 8.2 create methods that match action names changing colon to underscore (i.e., def buttonPressed_(self, sender); one web page said add @objc.IBAction above those methods but that didn't seem necessary) 9. in generated main.py, add import statement for my Python controller file
10. Build and Go

This seems to work for me and if I tell it to build a universal app and use the Release build, I can even copy the release build .app to other machines and run it.

Thanks,
Dave

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to