[Pythonmac-SIG] Running "freeze" on non-framework Python/universal binary issues

Bob Ippolito bob at redivi.com
Fri Jul 21 02:20:14 CEST 2006


On Jul 20, 2006, at 5:03 PM, Christopher Barker wrote:

>
> Bob Ippolito wrote:
>> On Jul 20, 2006, at 4:18 PM, Kevin Walzer wrote:
>>>> some fiddling in your main script if DISPLAY isn't set though.
>> If I were doing it I'd check for DISPLAY and look at the output of  
>> "/ usr/X11R6/bin/xauth list" to see if X11 is running.
>
> Another option is some C code I found posted on the net somewhere.  
> Rather than looking for DISPLAY, or xauth, it simply tries to  
> connect to the X server. You get an error if it doesn't work.
>
> I've only tested it on linux.
>
> I even made a Python module out of it.
>
> Code enclosed.

Well, trying to connect to an X11 server is only good if DISPLAY is  
already set. That's only going to be true if your application was  
started from the shell, more or less, so the majority of the time  
it's going to fail even if the X11 server is running.

Checking xauth will tell you if X11 is running, and what a reasonable  
guess for DISPLAY should be. It's possible to have a stale file  
though, so you might want to dig at the process table to see if X11  
is actually running.. or maybe send it an open apple event anyway,  
because you want to give it focus anyhow.

-bob



More information about the Pythonmac-SIG mailing list