Separate names with a comma.
Discussion in 'Mac Programming' started by Monkaaay, Nov 2, 2007.
I'm hoping to find some good information on Python/Cocoa specific to xcode 3.
I'm sure there's info on developer.apple.com. You can also find examples in /Developer/Examples/Python
No Good XCode 3 Python Tutorials
This isn't true. All that you can find on developer.apple.com and /Developer/Examples/Python are PyObjC examples, not XCode 3 examples. And for a beginner those are two completely different things.
It is incredibly frustrating because there are a ton of tutorials for PyObjC without XCode and a ton of tutorials for XCode 3 with Objective C but no freaking tutorials or examples using the Cocoa-Python template in XCode 3. It is very different than using either PyObjC or XCode with Objective C. Nothing you do in them works with a Cocoa-Python XCode project.
And so, I am screwed (I've been trying to get a simple button application to work for 2 days)..
The PyObjC "PyAverager" tutorial comes close
It has nice, reassuring videos of key operations. Most of the explanations are about how objects and operations are handled and translated by the bridge. Those parts are unchanged.
With a few caveats:
I forgot where I learned this, but main.py starts out missing the import for your module(s). Specifically, I had to add the line:
# import modules containing classes required to start application and load MainMenu.nib
import Averager # I had to add this line
In Xcode 2, the user interface definition lives in the a .nib file. In Xcode 3, this changes to .xib.
The biggest difference is Interface Builder. The old one just had a little pallet of exemplars you'd drag over (seen in the video). Interface Builder 3 has a huge pallet of objects, and (for a newbie) it's hard to find the right ones. For the example, all of the objects you want are NSTextFields. There are several different flavors (not subclasses, just initial settings, AFAICT) that are initialized for different uses. For example, you want "Label" for the two labels and two output fields, and you want a "Text Field Cell" for the input field.
But, even with that, I can't get PyAverager to work. I get errors that "this class is not key value coding-compliant for the key numbersInput" (and the two output fields, as well). I will start a new thread about that issue.
You can download Apple's PyAverager source and it works fine - although it uses the old .nib file, not .xib.
yup. Same error for me. I actually made an effort to understand Objective-C but it just looks like a mess. Python is way cleaner. I'm used to programming in Windows where ironically, there's more choice and ways to use high level languages like c# to make nice programs.
In that case there is no need for Xcode really.
Just download Smultron and read the Python documentation over at http://www.python.org/ and get stuck in. Leave Xcode for when you know the language and actually need it.
C# is available on the Mac too. Just look at the Mono Project.
Mac OS X is probably the best development platform out there as it has access to all the good things in Unix as well as the more consumer orientated background of the Mac OS.
Edit: Bah, I wish people wouldn't bump old threads .
Was it the Objective-C that was so messy for you? or was it the Foundation Framework/Cocoa stuff that you had issues with?
I'm still interested, in fact.
And, I still haven't found any resources out there. It's pretty frustrating, since the old examples, when PyObjC wasn't part of Xcode.
I might be able to whip up a tutorial or something. I don't really know Python but I was able to create a new project and added a button that beeps.
There is an older tutorial here which might help, but it uses an older version of Xcode.
Edit: been messing around a bit with this. Python is a royal PITA. Didn't realize how much of a whitespace Nazi it was. It is nice for keeping the amount of code down, but requires more work in IB than Objective-C and those extra underscores are getting annoying quickly
Python not so bad for me...
Python I can handle. KeyValueBindings and Controllers - those are mysterious and opaque.
The problem with something that's supposed to "just work" is that you're totally high and dry when it doesn't. Sigh.