Salome HOME
Merge multi-study removal branch.
[modules/gui.git] / tools / CurvePlot / src / python / pyqtside / __init__.py
1 """
2 Group under one hat PySide and PyQt4. PyQt4 is tried first.
3 """
4
5 try:
6   import os
7   if os.getenv("CURVEPLOT_FORCE_PYSIDE") is not None:
8     raise Exception
9   import PyQt4
10   _use_pyqt = True
11   print "Using PyQt4 run-time ..."
12 except:
13   try:
14     import PySide
15     _use_pyqt = False
16     print "Using PySide run-time ..."
17   except:
18     raise Exception("Neither PyQt4 nor PySide could be imported!")
19
20 # Matplotlib has to be handled very early, otherwise it will switch to whatever it
21 # finds first on the machine
22 try: 
23   import matplotlib
24   if _use_pyqt:  back = 'PyQt4'
25   else:          back = 'PySide'
26   matplotlib.rcParams['backend.qt4'] = back
27   print "Matplotlib found - Set matplotlib backend to '%s'!" % back 
28 except:
29   # No matplotlib, silently discard err message.
30   pass