2012-03-17 15:47:20 +00:00
|
|
|
## make this version of pyqtgraph importable before any others
|
2012-12-30 02:51:29 +00:00
|
|
|
## we do this to make sure that, when running examples, the correct library
|
|
|
|
## version is imported (if there are multiple versions present).
|
2012-03-17 15:47:20 +00:00
|
|
|
import sys, os
|
2012-12-30 02:51:29 +00:00
|
|
|
|
|
|
|
if not hasattr(sys, 'frozen'):
|
2013-02-25 18:03:21 +00:00
|
|
|
if __file__ == '<stdin>':
|
|
|
|
path = os.getcwd()
|
|
|
|
else:
|
|
|
|
path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
2012-12-30 02:51:29 +00:00
|
|
|
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)
|
|
|
|
|
2012-12-26 22:51:52 +00:00
|
|
|
## should force example to use PySide instead of PyQt
|
|
|
|
if 'pyside' in sys.argv:
|
2012-12-25 05:43:31 +00:00
|
|
|
from PySide import QtGui
|
2012-10-26 12:55:53 +00:00
|
|
|
elif 'pyqt' in sys.argv:
|
2012-12-25 05:43:31 +00:00
|
|
|
from PyQt4 import QtGui
|
2014-03-29 10:57:13 +00:00
|
|
|
elif 'pyqt5' in sys.argv:
|
|
|
|
from PyQt5 import QtGui
|
2012-12-25 05:43:31 +00:00
|
|
|
else:
|
|
|
|
from pyqtgraph.Qt import QtGui
|
2015-02-28 15:32:34 +00:00
|
|
|
|
|
|
|
import pyqtgraph as pg
|
2012-12-25 05:43:31 +00:00
|
|
|
|
2012-12-26 22:51:52 +00:00
|
|
|
## Force use of a specific graphics system
|
2015-02-28 15:32:34 +00:00
|
|
|
use_gs = 'default'
|
2012-12-25 05:43:31 +00:00
|
|
|
for gs in ['raster', 'native', 'opengl']:
|
|
|
|
if gs in sys.argv:
|
2015-02-28 15:32:34 +00:00
|
|
|
use_gs = gs
|
2012-12-25 05:43:31 +00:00
|
|
|
QtGui.QApplication.setGraphicsSystem(gs)
|
|
|
|
break
|
|
|
|
|
2015-02-28 15:32:34 +00:00
|
|
|
print("Using %s (%s graphics system)" % (pg.Qt.QT_LIB, use_gs))
|
|
|
|
|
2013-11-17 19:12:00 +00:00
|
|
|
## Enable fault handling to give more helpful error messages on crash.
|
|
|
|
## Only available in python 3.3+
|
|
|
|
try:
|
|
|
|
import faulthandler
|
|
|
|
faulthandler.enable()
|
|
|
|
except ImportError:
|
|
|
|
pass
|