FW: [Pythonmac-SIG] GUI apps appearing behind other apps on startup

Kevin Altis altis@semi-retired.com
Mon, 21 Apr 2003 17:31:48 -0700


-----Original Message-----
From: Jack Jansen [mailto:Jack.Jansen@oratrix.com]
Sent: Monday, April 21, 2003 3:31 AM
To: Kevin Altis
Cc: Robin Dunn
Subject: Re: [Pythonmac-SIG] GUI apps appearing behind other apps on
startup



On maandag, apr 21, 2003, at 01:10 Europe/Amsterdam, Kevin Altis wrote:
> Hi Jack,
> thanks for the solution. Unfortunately, there is no WMAvailable in 
> MacOS, at
> least in the MacOS module I have with 2.3a2. I did find the MacOS.so in
> python2.3:lib-dynload but other than importing it and inspecting the 
> module
> there isn't much I can do with it. I did grep for WMAvailable in the 
> Python
> 2.3 dir and sub-dirs but didn't find anything either.

Sorry, you're right, I added it after 2.3a2. It'll be there in 2.3b1.

> So, I decided to take this offlist so we could find the solution, 
> which may
> only be in cvs right now, and then I can post a summary. Assuming
> WMAvailable() will be in MacOS then your code can just be added at the 
> end
> of the wxPython app initialization:
>
>     if wx.wxPlatform == "__WXMAC__":
>         import MacOS
>         try:
>             # in case WMAvailable doesn't exist
>             # use a try/except block
>             MacOS.WMAvailable()
>         except:
>             # not much we can tell the user that would be useful
>             pass

Note that WMAvailable() is primarily meant as a safeguard against 
trying to do
windowing when you don't have access to the window manager (on 
OSX-server,
when not logged in). So the call is best done something like
try:
	if not MacOS.WMAvailable():
		print """This program needs access to the screen. Please run with
'pythonw', not 'python', and only when you are logged in on the main 
display
of your mac"""
		sys.exit(1)
except:
	pass

--
- Jack Jansen        <Jack.Jansen@oratrix.com>        
http://www.cwi.nl/~jack -
- If I can't dance I don't want to be part of your revolution -- Emma 
Goldman -