0

Perhaps this question is so simple, no one needs to ask it, or perhaps I am doing a poor job searching.

I would like to know how to write a simple Hello World program in python using XCode.

I see all over the place info about PyObjC, but I am not yet prepared for that.

Can someone point me to a tutorial or provide the relevant instructions?

I am using XCode 3.2.6 on Mac OS X 10.6.8.

Maybe once I can get Hello World working, I can begin thinking about creating an interface.

EMiller
  • 2,792
  • 4
  • 34
  • 55
  • possible duplicate of [Pure Python in Xcode?](http://stackoverflow.com/questions/2359994/pure-python-in-xcode) – agf Apr 12 '12 at 07:21
  • and related: [Pure Python in Xcode](http://stackoverflow.com/questions/3498839/pure-python-in-xcode) and [Python in Xcode 4](http://stackoverflow.com/questions/5276967/python-in-xcode-4) – agf Apr 12 '12 at 07:22
  • Granted I can just write python in any text editor, I would like to first be able to write simple scripts in XCode as a prelude to writing more complex applications with a GUI. Those other posts dismiss the original question. Can the question not be simply answered without proselytizing for another tool? – EMiller Apr 12 '12 at 17:19
  • Read them more closely. The question without the question mark in the title includes a step-by-step walkthrough of their use of Python with XCode, and a link to a tutorial on the subject. Even if they're not helpful, the solution isn't to post a duplicate question -- but to edit (or suggest an edit) to the existing questions, or offer a bounty, to attract more attention. – agf Apr 12 '12 at 19:06
  • I again read over that second link, and the tutorial it refers, and followed both of them to a tee as best as possible and it still fail. It was that frustration that originally led me to post this question. The problem may be that I can't follow this: From 'Pure Python' I selected 'Python tool', named it main.py then clicked finish. For me, there is no 'Python tool' in my XCode. – EMiller Apr 14 '12 at 15:44

1 Answers1

1

There are a couple options. If you want to write just pure python you can do that in any text editor.

If you want to convert a python script to an app there is py2app. With Xcode 3 there is an app that does this in /Developer/Applications. I don't have Xcode 3 anymore so I can't give the specifics of where exactly this app is but It's somewhere under /Developer :)

If you want to build an mac app with python you'll need to use PyObjC to interact with the necessary NSObjects. Here is an old app I built with PyObjC that you might find useful: RockStar.

keegan3d
  • 10,357
  • 9
  • 53
  • 77
  • That py2app is quite interesting. I don't see it in my copy of XCode 3. Maybe it is XCode 4? I do see the Build Applet application in /Developer/Applications/Utilities/Python2.6 but it fails to let me select a simple hello_world.py script. – EMiller Apr 12 '12 at 17:05
  • Oh and by the way, that RockStar app is really cool. That's something I would love to be able to do. – EMiller Apr 12 '12 at 17:11
  • I'm on a machine now with Xcode3 and yes `/Developer/Applications/Utilities/Python 2.6/Build Applet.app` is the app I was talking about. The way I've always used it is by dragging a python script onto the icon, give that a try. RockStar was a fun learning experience, it's a now a native app: http://itunes.apple.com/us/app/rockstar/id412379768?mt=12 – keegan3d Apr 12 '12 at 17:47