I'm planning to do a screencast for this, but knowing myself, I'll just put the code here in case I run off to a different direction tomorrow...
So, I present a lightly annotated hello world app in PyObjC! Only works on Mac OS X 10.5.2.
Download PyObjC tutorial (24 KB)
QTMovieView, a label and a button
- Cocoa Bindings to Python attributes
- Notifications and selectors
When you roll your own, here are some tips:
Don't forget that
IBOutlets must be class level
Always initialize things you bind to (
Nonewill do), or you will get nasty obscure errors
if you have other Pythons installed (eg. Macports), do:
alias macpython= /System/Library/Frameworks/Python.framework/Versions/2.5/bin/pythonand use that. Also remove other Pythons installed in /Library/Frameworks or Xcode might get confused.
If the app isn't launching, do
macpython main.pyand check for syntax errors (you can't launch it)
- If you don't get the expected behaviour, check the console for swallowed errors.
This post is older than 30 days and comments have been turned off.