[Pythonmac-SIG] How to tell if a .app is clicked again?

Chris Barker Chris.Barker at noaa.gov
Tue Aug 16 21:31:11 CEST 2005


Hi all,

I'm working on a project in which we're trying to write a Web app that 
can also be run stand-alone on a non-networked machine. so far, I've got 
a little demo that creates a tiny little database-backed web site using:

Quixote
Cheetah
SQLite
pysqlite

If it's run as __main__, it starts up a little server (using Quixote 
SimpleServer) listening to localhost:8080, then uses the webbrowser 
module to start up a web browser pointing to that address. This all 
works great. In fact, I can use py2app to bundle it all up, and get a 
nice distributable clickable app that the user can click on and it fires 
up the web browser and away we go..

NOTE: Thanks Bob for py2app: It worked absolutely flawlessly for this, 
with no tweaking or anything...I'm not looking forward to the py2exe 
version....

So here's the issue:

When you start the app, it puts a little icon on the dock, and fires up 
the browser, all is good. However, if you try to start the app again, it 
doesn't do anything, as it's already running. I don't want it to start 
up again, but it would be nice if it would bring up the browser again.

I'm imagining that some sort of event is sent to the app when the user 
tries to start it up again. I'd like to catch that event and then start 
up the browser again. How would I do that...I've really only programmed 
in  Linux/Unix style and with wxPython, so I have no clue about Apple 
events and the like.

Another issue:
It puts an icon in the dock, but I don't have any wxWindows or anything, 
so it doesn't do much. The only way I can figure out how to stop it is 
to right click on the icon in the dock and select force quit. I see two 
possible solutions:

1) Have it not put an icon in the dock, and just run in the background. 
then it would just keep running forever, which would probably be OK, or 
I could have it automatically quit if it hadn't been used for some 
period of time. How do you have an app started with a double-click run 
without an icon in the dock?

2) Give it a menu, with a the usual quit, etc. items. As it doesn't have 
a window, I'm not sure it this is so good, but it might be a little more 
Mac-like. If I do this, what is the lightest weight way to give it a 
menu with the basic items.

Any thoughts are welcome.

-Chris

-- 
Christopher Barker, Ph.D.
Oceanographer
                                     		
NOAA/OR&R/HAZMAT         (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov


More information about the Pythonmac-SIG mailing list