[PyQt] Get platform?

Hans-Peter Jansen hpj at urpla.net
Wed Feb 16 15:45:47 GMT 2011


On Tuesday 15 February 2011, 17:57:01 mw wrote:
> import os
> os.name
>
> http://docs.python.org/library/os.html
>
> On Tue, Feb 15, 2011 at 8:51 AM, todd rme <toddrme2178 at gmail.com> 
wrote:
> > Is there any way inside pyqt, or in python, to determine what
> > platform you are using?  Specifically, I want to know if the widget
> > is done in x11.  I don't think I can check for x11 environment
> > variables since I at least think mac can have x11 installed without
> > using it for Qt.  I need to know if the actual pyqt4 window is
> > using X11.

Just try to instantiate e.g. QtGui.QX11Info(), it will throw an 
NameError exception, if this platform isn't X11 aware. This call will 
succeed even if X isn't running, btw. You might check that with 
QtGui.QX11Info.appRootWindow().

This procedure will fail, it somebody builds PyQt with a X11 disabled 
Qt, but that's pretty unlikely..

Pete


More information about the PyQt mailing list