projects
/
lilass.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f9da065
)
rework GUI frontend selection
author
Ralf Jung
<post@ralfj.de>
Wed, 17 Oct 2012 14:20:21 +0000
(16:20 +0200)
committer
Ralf Jung
<post@ralfj.de>
Wed, 17 Oct 2012 14:20:21 +0000
(16:20 +0200)
gui.py
patch
|
blob
|
history
diff --git
a/gui.py
b/gui.py
index 83099e884b0bbd50cef5700fd26f6da5d4902f96..155226b3939fff4598786870baa61b3aedf13396 100644
(file)
--- a/
gui.py
+++ b/
gui.py
@@
-18,26
+18,36
@@
# This file abstracts GUI stuff away, so that the actual dsl.py does not have to deal with it
import sys
# This file abstracts GUI stuff away, so that the actual dsl.py does not have to deal with it
import sys
-qt_available = True
-try:
+# frontend detectors
+def qtAvailable():
+ try:
+ import PyQt4
+ return True
+ except ImportError:
+ return False
+
+def zenityAvailable():
+ return True # FIXME
+
+# actual frontend
+if qtAvailable():
from PyQt4 import QtGui
from qt_dialogue import PositionSelection
app = QtGui.QApplication(sys.argv)
from PyQt4 import QtGui
from qt_dialogue import PositionSelection
app = QtGui.QApplication(sys.argv)
-except Exception, e:
- import subprocess
- from zenity_dialogue import run as zenity_run
- qt_available = False
-
-def error(message):
- '''Displays a fatal error to the user'''
- if qt_available:
+
+ def error(message):
+ '''Displays a fatal error to the user'''
QtGui.QMessageBox.critical(None, 'Fatal error', message)
QtGui.QMessageBox.critical(None, 'Fatal error', message)
- else:
- subprocess.check_call(["zenity", "--error", "--text="+message])
-
-def setup(internalResolutions, externalResolutions):
- '''Returns a ScreenSetup instance, or None if the user canceled'''
- if qt_available:
+
+ def setup(internalResolutions, externalResolutions):
+ '''Returns a ScreenSetup instance, or None if the user canceled'''
return PositionSelection(internalResolutions, externalResolutions).run()
return PositionSelection(internalResolutions, externalResolutions).run()
- else:
- return zenity_run(internalResolutions, externalResolutions)
+elif zenityAvailable():
+ import subprocess
+ from zenity_dialogue import run as setup # this provides the setup function
+
+ def error(message):
+ '''Displays a fatal error to the user'''
+ subprocess.check_call(["zenity", "--error", "--text="+message])
+else:
+ print >> sys.stderr, 'No GUI frontend available, please make sure PyQt4 or Zenity is installed'