Refactoring to avoid the _gtk_DrawingArea kludge
[pysize.git] / ui / gtk / ui_gtk.py
blob2e5639da3cd15c6a1b33e67040572ee89621e020
1 import os
2 from pysize_window import PysizeWindow
4 # This is evil, we test for gtk in a separate process
5 # because 'import gtk' breaks curses on a linux console.
6 pid = os.fork()
7 if pid == 0:
8 try:
9 import cairo, pygtk
10 pygtk.require('2.0')
11 import gtk
12 assert gtk.pygtk_version >= (2, 8)
13 os._exit(0)
14 except Exception, e:
15 os._exit(1)
16 else:
17 (p, status) = os.waitpid(pid, 0)
18 IS_AVAILABLE = os.WIFEXITED(status) and os.WEXITSTATUS(status) == 0
20 def run(options, args):
21 PysizeWindow(options, args)
23 def is_available():
24 return IS_AVAILABLE