PDA

View Full Version : Any tutorials out there for Python/Cocoa in xcode 3 yet?




Monkaaay
Nov 2, 2007, 08:56 PM
I'm hoping to find some good information on Python/Cocoa specific to xcode 3.



kainjow
Nov 4, 2007, 07:26 AM
I'm sure there's info on developer.apple.com. You can also find examples in /Developer/Examples/Python

credford
Jun 5, 2008, 02:52 PM
I'm sure there's info on developer.apple.com. You can also find examples in /Developer/Examples/Python

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).. :(

trewitt
Jul 13, 2008, 12:24 AM
http://developer.apple.com/cocoa/pyobjc.html
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 MyAveragerAppDelegate
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.

xster
Mar 24, 2009, 10:20 PM
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.

Cromulent
Mar 24, 2009, 10:23 PM
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.

In that case there is no need for Xcode really.

Just download Smultron (http://tuppis.com/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.

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.

C# is available on the Mac too. Just look at the Mono Project (http://www.mono-project.com/Main_Page).

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 :(.

GorillaPaws
Mar 24, 2009, 10:38 PM
I actually made an effort to understand Objective-C but it just looks like a mess.

Was it the Objective-C that was so messy for you? or was it the Foundation Framework/Cocoa stuff that you had issues with?

trewitt
Mar 26, 2009, 12:49 PM
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.

kainjow
Mar 26, 2009, 01:14 PM
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 (http://www.cs.usfca.edu/~jbovet/pyobjc/tutorial/tutorial.html) 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 :)

trewitt
Mar 26, 2009, 08:52 PM
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.