initExample.py 1.11 KB
Newer Older
Luke Campagnola's avatar
Luke Campagnola committed
1
## make this version of pyqtgraph importable before any others
2 3
## we do this to make sure that, when running examples, the correct library
## version is imported (if there are multiple versions present).
Luke Campagnola's avatar
Luke Campagnola committed
4
import sys, os
5 6 7 8 9 10 11 12 13 14 15 16 17 18

if not hasattr(sys, 'frozen'):
    path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
    path.rstrip(os.path.sep)
    if 'pyqtgraph' in os.listdir(path):
        sys.path.insert(0, path) ## examples adjacent to pyqtgraph (as in source tree)
    else:
        for p in sys.path:
            if len(p) < 3:
                continue
            if path.startswith(p):  ## If the example is already in an importable location, promote that location
                sys.path.remove(p)
                sys.path.insert(0, p)

19 20
## should force example to use PySide instead of PyQt
if 'pyside' in sys.argv:  
21
    from PySide import QtGui
22
elif 'pyqt' in sys.argv: 
23 24 25 26
    from PyQt4 import QtGui
else:
    from pyqtgraph.Qt import QtGui
    
27
## Force use of a specific graphics system
28 29 30 31 32
for gs in ['raster', 'native', 'opengl']:
    if gs in sys.argv:
        QtGui.QApplication.setGraphicsSystem(gs)
        break