Any tutorials out there for Python/Cocoa in xcode 3 yet?

Discussion in 'Mac Programming' started by Monkaaay, Nov 2, 2007.

  1. Monkaaay macrumors 6502


    Jun 19, 2006
    Richmond, VA
    I'm hoping to find some good information on Python/Cocoa specific to xcode 3.
  2. kainjow Moderator emeritus


    Jun 15, 2000
    I'm sure there's info on You can also find examples in /Developer/Examples/Python
  3. credford macrumors newbie

    Jun 5, 2008
    No Good XCode 3 Python Tutorials

    This isn't true. All that you can find on 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).. :(
  4. trewitt macrumors newbie

    Jul 23, 2002
    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:
    1. I forgot where I learned this, but 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.
  5. xster macrumors newbie

    Nov 25, 2008
    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.
  6. Cromulent macrumors 603


    Oct 2, 2006
    The Land of Hope and Glory
    In that case there is no need for Xcode really.

    Just download Smultron and read the Python documentation over at 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 :(.
  7. GorillaPaws macrumors 6502a


    Oct 26, 2003
    Richmond, VA
    Was it the Objective-C that was so messy for you? or was it the Foundation Framework/Cocoa stuff that you had issues with?
  8. trewitt macrumors newbie

    Jul 23, 2002
    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.
  9. kainjow Moderator emeritus


    Jun 15, 2000
    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 :)
  10. trewitt macrumors newbie

    Jul 23, 2002
    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.

Share This Page