Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
I'm sure there's info on developer.apple.com. You can also find examples in /Developer/Examples/Python
 

credford

macrumors newbie
Jun 5, 2008
1
0
No Good XCode 3 Python Tutorials

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

macrumors newbie
Jul 23, 2002
4
0
The PyObjC "PyAverager" tutorial comes close

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:
  1. 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
  2. In Xcode 2, the user interface definition lives in the a .nib file. In Xcode 3, this changes to .xib.
  3. 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.
  4. 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

macrumors newbie
Nov 25, 2008
4
0
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

macrumors 604
Oct 2, 2006
6,802
1,096
The Land of Hope and Glory
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 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.

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

trewitt

macrumors newbie
Jul 23, 2002
4
0
Still Interested...

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

Moderator emeritus
Jun 15, 2000
7,958
7
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 :)
 

trewitt

macrumors newbie
Jul 23, 2002
4
0
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.