Re: [Pythonmac-SIG] How to tell if a .app is clicked again?
Hi Chris, Sorry for the late reply. ;-/ On Aug 16, 2005, at 1:31 PM, Chris Barker wrote: Kevin Ollivier wrote: I can't answer the questions you posed below, as I do almost all of my Mac work with wxPython, but when I read about what you're trying to do I couldn't help but think that this is exactly what ActiveGrid AppBuilder is for: http://www.activegrid.com Granted, it's wxPython and thus not as lightweight, but apps you create with it can be run locally on the user's machine or can be deployed to a server with their server components installed. It allows you to use SQLite, Oracle, MySQL, or PostGreSQL for the database. It's also pretty nice for point-and-click creation of full- fledged database apps, so the apps are easy to customize. (See their Petstore demo that comes with the app.) Not sure what your exact needs are, but this might be at least worth a look if you haven't seen it already. No, I hadn't. It's a little hard to tell what the heck it really is from the web page..the usual marketing-speak, no mention of wx, for instance. It's basically a web app development tool. The big benefit is that you can use it to very quickly throw this sort of app together (you can just point it at a database, tell it what forms you want, and it'll draft a web app for you), which is why I thought you may be interested in it. It sets up a local server automatically (based on Python's httpserver, like Quioxte, CherryPy, etc.) so that users can run and test the web app locally, and then there's a set of server components to install to a server. So it'd be similar to your situation now where you'd use py2app/py2exe to bundle the server components and your web app together. Of course, if you've already got a static web-app built that you just want to be able to run on machines with no (or slow) internet access, then there's probably no need to switch tools. I haven't done a bake- off of the various httpserver-based web servers out there, so I can't say for sure which one best deals with the various quirks in various browsers. (I know that ActiveGrid's server handles the IE post bug fine where it sends an extra two byte line feed sometimes.) However, these are our needs: The web version needs to run on a basic browser, with not extra plug-ins or custom clients. We'd like to make the stand-alone version share as much code as possible with the web version. That means the same GUI, which means it would run in a browser. It also needs to be a simple install, i.e. not MySQL + apache + our app. Activegrid really doesn't seem to provide this, but I'll look into it more. While I'm talking to Kevin: The other idea I had was to use wxMozilla, to embed a browser in a wxPython app, then we could use the same code to generate all the HTML, and display the UI through wxMozilla, without having to use a client-server set up and http. This came up because apparently some Windows systems turn off all TCP/IP when the Ethernet cable is disconnected. My question is: with wxMozilla, can you capture all the GET and/or POST events, so that you can essentially run a web app and browser all within one process? At present at least, there's no way to do this using wxMozilla. There're probably ways to do this using some Mozilla hacks, but I doubt they'd be supported. And considering that even Mozilla's primary embedding interface is still (as of 1.7.x) considered a 'private' interface subject to change, I'm not sure you could even rely on the hack to continue working in the future. The server route is a bit of a pain but is probably the more sustainable solution in the long run. Kevin -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/ORR/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
[Pythonmac-SIG] How to tell if a .app is clicked again?
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/ORR/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] How to tell if a .app is clicked again?
On Tue, Aug 16, 2005 at 09:51:57AM -1000, Bob Ippolito wrote: IIRC, on Mac OS X, there isn't a difference between re-launching and becoming active. Double-clicking the app should have the same behavior as cmd-tabbing over to it (or using expos?, or the dock, etc.), because LaunchServices recognizes that the application is already open and just tells it to activate. It used to be, back in System 7, but at some point (7.6? 8.0?) the 'aevt'/'rapp' (kAEReopenApplication) event was sent when an application is double-clicked in the Finder and is already open. The same occurs when you click on the application's dock icon in OS X. You can test this, for example, with TextEdit. Open it, close the untitled window, switch somewhere else, then cmd-tab to it: you don't get an untitled window. Then switch somewhere else and click on its icon in the dock: you do get an untitled window. 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: It depends on the Web server you're using and how well it fits with CF/NSRunLoop and friends. Chris might be able to run a regular PyObjC app (from which you can easily set up a NSApplication delegate to implement applicationShouldHandleReopen_hasVisibleWindows_) and the Web server in other threads, or not... -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] How to tell if a .app is clicked again?
Kevin Ollivier wrote: I can't answer the questions you posed below, as I do almost all of my Mac work with wxPython, but when I read about what you're trying to do I couldn't help but think that this is exactly what ActiveGrid AppBuilder is for: http://www.activegrid.com Granted, it's wxPython and thus not as lightweight, but apps you create with it can be run locally on the user's machine or can be deployed to a server with their server components installed. It allows you to use SQLite, Oracle, MySQL, or PostGreSQL for the database. It's also pretty nice for point-and-click creation of full- fledged database apps, so the apps are easy to customize. (See their Petstore demo that comes with the app.) Not sure what your exact needs are, but this might be at least worth a look if you haven't seen it already. No, I hadn't. It's a little hard to tell what the heck it really is from the web page..the usual marketing-speak, no mention of wx, for instance. However, these are our needs: The web version needs to run on a basic browser, with not extra plug-ins or custom clients. We'd like to make the stand-alone version share as much code as possible with the web version. That means the same GUI, which means it would run in a browser. It also needs to be a simple install, i.e. not MySQL + apache + our app. Activegrid really doesn't seem to provide this, but I'll look into it more. While I'm talking to Kevin: The other idea I had was to use wxMozilla, to embed a browser in a wxPython app, then we could use the same code to generate all the HTML, and display the UI through wxMozilla, without having to use a client-server set up and http. This came up because apparently some Windows systems turn off all TCP/IP when the Ethernet cable is disconnected. My question is: with wxMozilla, can you capture all the GET and/or POST events, so that you can essentially run a web app and browser all within one process? -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/ORR/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] How to tell if a .app is clicked again?
On Tue, Aug 16, 2005 at 03:02:04PM -0700, Chris Barker wrote: Well, it's not, but that is an idea. If I have a little launcher stub, it could just check and see what's running, and then launch what it needs to, then quit. That way it would just get started up again if the user double clicked again, and then do what it needed to. That would require more than one app to be installed, however. Which leads me to another idea: Can I tell OS-X that I DO want another instance of the app launched rather than raising an existing one? That way, I could do the Windows trick: On launch, check for an existing one, of it's there, start the browser and quit. If it's not, start the server, then the browser, and don't quit. This would let me have the app and the launching stub be the same app. You can do this (LaunchServices lets you multi-launch apps, or you can always execute the binary directly), but not from the Finder. However, you could do something slightly different, and closer to your first idea: embed the actual app inside the launcher app's bundle. Then start your real app, with an icon or not, when the launcher app runs; the launcher app would then exit. If the launcher app notes that the real app is already running, then just open the page in the browser. The user would only see one app, and since the Finder in OS X no longer shows apps differently when they're open, they'd never know the difference. -- Nicholas Riley [EMAIL PROTECTED] | http://www.uiuc.edu/ph/www/njriley ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] How to tell if a .app is clicked again?
Nicholas Riley wrote: Which leads me to another idea: Can I tell OS-X that I DO want another instance of the app launched rather than raising an existing one? You can do this (LaunchServices lets you multi-launch apps, or you can always execute the binary directly), but not from the Finder. Darn. However, you could do something slightly different, and closer to your first idea: embed the actual app inside the launcher app's bundle. Then start your real app, with an icon or not, when the launcher app runs; the launcher app would then exit. If the launcher app notes that the real app is already running, then just open the page in the browser. The user would only see one app, and since the Finder in OS X no longer shows apps differently when they're open, they'd never know the difference. I like this. Now I have to figure out how to put another app inside a Py2app'd bundle. The main app and the one inside would both be python apps. It looks to me like a Py2app bundle has a little stub as the executable. Could I build two py2app bundles, of two different scripts, then just drag the executable from one into the other to get two in one, that would share all the resources? I guess I'll go try. -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/ORR/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] How to tell if a .app is clicked again?
On Aug 16, 2005, at 1:10 PM, Chris Barker wrote: Nicholas Riley wrote: Which leads me to another idea: Can I tell OS-X that I DO want another instance of the app launched rather than raising an existing one? You can do this (LaunchServices lets you multi-launch apps, or you can always execute the binary directly), but not from the Finder. Darn. However, you could do something slightly different, and closer to your first idea: embed the actual app inside the launcher app's bundle. Then start your real app, with an icon or not, when the launcher app runs; the launcher app would then exit. If the launcher app notes that the real app is already running, then just open the page in the browser. The user would only see one app, and since the Finder in OS X no longer shows apps differently when they're open, they'd never know the difference. I like this. Now I have to figure out how to put another app inside a Py2app'd bundle. The main app and the one inside would both be python apps. It looks to me like a Py2app bundle has a little stub as the executable. Could I build two py2app bundles, of two different scripts, then just drag the executable from one into the other to get two in one, that would share all the resources? I guess I'll go try. Nope that doesn't work.. What you should do is simply re-execute the same application with different command line arguments. LaunchServices won't pick up on the second launch because it was done outside of LaunchServices. -bob ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig