Added is_quartz() and has_display() functions to tell if running with quartz window manager, and if have a display, respectively. See #4467 for more details

svn: r16307
This commit is contained in:
Doug Blank
2010-12-23 16:51:04 +00:00
parent f009c7a1f5
commit 3833ee63a6
8 changed files with 126 additions and 13 deletions

View File

@@ -77,3 +77,35 @@ def win():
if platform.system() in WINDOWS:
return True
return False
## The following functions do import gtk, but only when called. They
## should only be called after translation system has been
## initialized!
def is_quartz():
"""
Tests to see if Python is currently running with gtk and
windowing system is Mac OS-X's "quartz".
"""
if mac():
try:
import gtk
except:
return False
return gtk.gdk.WINDOWING == "quartz"
return False
def has_display():
"""
Tests to see if Python is currently running with gtk and
windowing system is Mac OS-X's "quartz".
"""
try:
import gtk
except:
return False
try:
gtk.init_check()
return True
except:
return False