views:

256

answers:

3

I've written a nice Python application that is basically an HTTP proxy for SMS modems, and I'd like to make it a double-clickable application on Macs. So far I've been including a .commmand file which is double-clickable, which basically consists of

cd `dirname $0`
(sleep 8;open http://127.0.0.1:8080/)&
mac/slingshotsms.app/Contents/MacOS/slingshotsms

How can I make the main .app executable call a different place / or what's the easiest way to make an application that is basically a wrapper for a terminal utility and only displays its output? Currently double-clicking on the application will use the open utility on Macs - I want to emulate the behavior of double-clicking on Contents/MacOS/slingshotsms when double-clicking on the application icon. any tips?

+1  A: 

If you're looking for 'easy', try just giving your python script a .command suffix, and make sure it's executable. For example:

#!/usr/bin/env python
# file: hello.command

print 'hello world'

If you're looking for 'polished', then you probably want to learn about Launch Services, PyObjC, Interface Builder, NIB files, app wrappers, and all sorts of Mac OS X-specific technology details. But, note that PyObjC is nearly impossible to use for anything non-trivial without already knowing, more or less, how to do the same task using the Objective-C Cocoa APIs. PyObjC is a fairly thin wrapper around those APIs, and you have to know the Cocoa idioms / design patterns to understand how the moving parts fit together.

Matt Anderson
Hey,I'm using py2app and the setuptools system so that I can have all of the dependencies of this app packaged and a Python environment included... so having a .command file doesn't really jive here.
A: 

Write an AppleScript application that launches Terminal and runs your Python script (which will be inside the application's bundle).

Azeem.Butt
A: 

If you don't actually need a terminal, but instead just want an app wrapper around a script, have a look at Platypus

cobbal