[Pythonmac-SIG] How to create a desktop alias to run a python file?

Jack Jansen Jack.Jansen at cwi.nl
Sat Mar 24 00:24:08 CET 2007


On  23-Mar-2007, at 22:27 , Alfred Morgan wrote:
> #!/bin/sh
> cat > /tmp/alfred_hw.py << .
> from Tkinter import Tk, Label
> r=Tk()
> Label(r, text="Hello World").pack()
> r.mainloop()
> .
> mkdir ~/Desktop/alfred_hw.app
> cat  > ~/Desktop/alfred_hw.app/alfred_hw << .
> #!/usr/bin/env pythonw /tmp/alfred_hw.py
> .
> chmod +x ~/Desktop/alfred_hw.app/alfred_hw

Yes, this one works for me just fine!!

I'm very surprised, because it does not follow any Apple guideline  
for application bundles that I've ever seen. (Also, I don't know what  
I did differently yesterday when it didn't work for me, but never  
mind that). BTW: you can make things even simpler by putting the  
Python code into alfred_hw. And moreover you don't need pythonw,  
apparently because you're in an App bundle already:

#!/bin/sh
mkdir ~/Desktop/alfred_hw.app
cat  > ~/Desktop/alfred_hw.app/alfred_hw << .
#!/usr/bin/env python
from Tkinter import Tk, Label
r=Tk()
Label(r, text="Hello World").pack()
r.mainloop()
.
chmod +x ~/Desktop/alfred_hw.app/alfred_hw


Is anyone else familiar with such simple .app bundles?
--
Jack Jansen, <Jack.Jansen at cwi.nl>, http://www.cwi.nl/~jack
If I can't dance I don't want to be part of your revolution -- Emma  
Goldman


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20070324/6e87b928/attachment.htm 


More information about the Pythonmac-SIG mailing list