views:

2835

answers:

6

I am about to start my A-Level Computing project (High School Level) which will hopefully be a point-of-sale application for Mac OS. Unfortunately, Objective-C is a little out of my league at the moment and should I get stuck with it in the project I have no one to help out so I would fail the section of the course and not get into University. So this is quite important to me.

I want to use Python to develop a Cocoa app. I know that I need PyObjc, however all details on the net seem to assume it is pre-installed. Apparently this is the case with Leopard and Snow Leopard but I don't seem to have it on Snow Leopard and never noticed it on Leopard. Also, I have tried installing the latest beta of PyObjc by following the instructions on the Sourceforge page, but with no luck.

I would really appreciate it if anyone could shed some light on what needs to be installed, how, and links to any resources or tutorials that could help me.

Thanks in advance for the help!

Update: I see that this is a popular question, I just got the 'Notable Question' badge for it so I thought I would update anyone coming to this page on what I did after getting the answers.

Unfortunately, I wasn't able to use Python to create a Mac application. This was rather disappointing at the time, but probably a good thing. I made a Windows app in C# for my project, it was a tool for creating and running Assembly apps in a simulated environment. My course teacher has now started to use my tool to teach the course instead of his own! I got a very high score on the computing project (over 90%) and this contributed to me getting an A* in my computing A-Level (the highest grade available) and I consequently got in to Southampton University to study Computer Science.

This summer, I decided to make an iPad app (soon to be released) and I am glad to say that I know think I could make a Mac OS application in Objective-C as I feel I have learnt enough. I am glad that I took the time to learn it, it is a great language and really useful with iOS becoming so popular.

Sorry for all the boasting, but I am really happy about it. What I really want to say is, if you are coming to this page hoping to use PyObjc to create Mac apps easily, don't bother. It takes some time and some effort, but once you have learnt Objective-C, it is really satisfying to create apps with it. Good Luck!

+6  A: 

You mean like Checkout? :-) I only mention it because Checkout is gorgeous and written with PyObjC...

Your concerns are valid, although probably not as much of a potential showstopper as you'd think. Using PyObjC still requires you to learn some Objective-C, and definitely requires you to understand at least some of the Cocoa frameworks, since you need to call into the Cocoa frameworks whenever you need to do some sort of Cocoa-specific task.

I recommend you read and consider the SO question "Why is the PyObjC documentation so bad?" and "PyObjc vs RubyCocoa for Mac development: Which is more mature?" before you completely convince yourself that "just PyObjC" will make things much easier. I refuse to disparage PyObjC because it is quite powerful and incredibly useful, but realize that nothing is a silver bullet, and no language or technology is best for all problems.

The Objective-C language is simple and pretty straightforward. The Cocoa frameworks generally dominate the learning curve for new Cocoa programmers. Plus, you have StackOverflow and lots of other resources to help answer your questions. (Judging by the activity of the "pyobjc" tag, you also stand a better chance of getting good Objective-C help on SO.)

Quinn Taylor
+3  A: 

I hardly use PyObjC myself, but I believe you need to run the Xcode installer on the Snow Leopard DVD in order to use PyObjC.

Also, as Quinn said, you will need to understand at least some Objective-C in order to use a Cocoa bridge like PyObjC without tearing your hair out. It just doesn't insulate you that completely.

Chuck
+3  A: 

I'm going to agree with Quinn here. Even if you're already proficient in Python, learning how to interface Python and Cocoa is not going to be any easier than learning Cocoa with Objective-C.

Objective-C is a simple, clean language that is quite easy to grok. Building the GUI and hooking it up to the back-end will be harder than learning the Objective-C to write the back-end, and building the GUI and hooking it up isn't that hard.

Follow the Cocoa app tutorial (you should be able to get through it in a day, or maybe a weekend if you go slow) and you'll be well on your way.

alesplin
+4  A: 

And as one of the Checkout developers I'll weigh in too (hi Quinn!). From what we've seen PyObjC runs fairly well on Snow Leopard. We've built one of the latest SVN revisions 2.2b with some customizations on Leopard and just moved over the site-packages folder.

Theoretically you should be able to use the built in Python/PyObjC (just do import objc, Foundation, AppKit) but as we ship/work with custom versions of both Python and PyObjC I'm not sure what the status exactly is. The mailing list doesn't mention a lot of people having issues (just a few) so that could be a good sign.

Good luck with the project, and if you have specific POS questions shoot me an email ;-)

Koen Bok
+15  A: 

Allow me to echo what has already been said. I too am a student who just started a Cocoa development project, and at the beginning I thought "Well, I already know Python, I'll just use PyObjC and save myself from having to learn Objective-C, which looks beyond my grasp." I learned quickly that it can't be done. You can develop for OS X without learning Objective-C, but not without learning the Cocoa libraries, which constitute 99% of what you need to learn to write a Cocoa app in Objective-C. Objective-C itself isn't that hard; it's the Cocoa libraries that you need to invest in learning.

PyObjC basically uses Cocoa libraries and Python syntax. I gave up with it quickly and decided that if I was going to have to learn Cocoa, I may as well use Objective-C.

If you're looking to learn, Aaron Hillegass's book is a good place to start. Good luck!

Ellie P.
Ok, I won't post comments on all the questions, but let me say thanks to the support from everyone. I really appreciate it!I have installed the developer stuff from the disc already, but the PyObjc stuff isn't there in Xcode.The reason I am reluctant to use Objc is because if I get stuck there is possibly a Uni place at stake, and considering I want to study CS, I can't afford to not get an A in this work.Also, thanks to Koen! It is actually a POS app I am going to write and Checkout inspired me to use PyObjc.Thanks to everyone again, you have persuaded me to use pure Objc I think.
danpalmer
Oh, and I already have Aaron Hillegass' book, but the fact it includes the code for memory management scared me a little.
danpalmer
FYI, the biggest reason for us to write Checkout in Python was SQLAlchemy, a great ORM. I think if that wasn't the case, I would use Obj-C too.
Koen Bok
bbum
If you don't want to deal with the memory management, turn on garbage collection and either ignore the MM code in the Hillegass book, or include it in your program. If you have GC turned on, the MM code won't do anything.
Ellie P.
It certainly true. To learn Cocoa, you need to learn Objective-c. PyObjC might be a good solution to port a python application to osx; it would be good to know how to get started with PyObjC on Snow Leopard... E.g, Where are the xcode template for PyObjC. I remember them on Leopard (i think). I can't find them on Snow Leopard.
Dinoboff
+2  A: 

I'm a long time python developer who's been doing iPhone apps for awhile now (and only using my python knowledge to package up build files for the apps in run scripts), then who started making some PyObjC apps.

I'd have to say, PyObjC is pretty much STILL having to learn objective C (which I already know via iPhone dev), however you get several pretty cool benefits if you use it instead

  • Easy use of python libraries you know (faster for you)
  • Option to drop it and go to wxPython if styimied by Cocoa
  • Somewhat faster development time (you're writing less code, and the translation between the two languages is pretty darn easy to get used to).

Additionally, interface builder is a little tricky to get used to comparatively speaking, but if you're a python dev, it's not like you're exactly used to a functional gui builder anyhow :oP

Michael Langford