move mkQApp to Qt.py to make it easier to import internally
GraphicsLayoutWidget now calls mkQApp
This commit is contained in:
parent
afd8a6f423
commit
927fe44ab9
@ -272,3 +272,10 @@ m = re.match(r'(\d+)\.(\d+).*', QtVersion)
|
|||||||
if m is not None and list(map(int, m.groups())) < versionReq:
|
if m is not None and list(map(int, m.groups())) < versionReq:
|
||||||
print(list(map(int, m.groups())))
|
print(list(map(int, m.groups())))
|
||||||
raise Exception('pyqtgraph requires Qt version >= %d.%d (your version is %s)' % (versionReq[0], versionReq[1], QtVersion))
|
raise Exception('pyqtgraph requires Qt version >= %d.%d (your version is %s)' % (versionReq[0], versionReq[1], QtVersion))
|
||||||
|
|
||||||
|
|
||||||
|
def mkQApp():
|
||||||
|
app = QtGui.QApplication.instance()
|
||||||
|
if app is None:
|
||||||
|
app = QtGui.QApplication([])
|
||||||
|
return app
|
||||||
|
@ -10,7 +10,7 @@ __version__ = '0.10.0'
|
|||||||
|
|
||||||
## 'Qt' is a local module; it is intended mainly to cover up the differences
|
## 'Qt' is a local module; it is intended mainly to cover up the differences
|
||||||
## between PyQt4 and PySide.
|
## between PyQt4 and PySide.
|
||||||
from .Qt import QtGui
|
from .Qt import QtGui, mkQApp
|
||||||
|
|
||||||
## not really safe--If we accidentally create another QApplication, the process hangs (and it is very difficult to trace the cause)
|
## not really safe--If we accidentally create another QApplication, the process hangs (and it is very difficult to trace the cause)
|
||||||
#if QtGui.QApplication.instance() is None:
|
#if QtGui.QApplication.instance() is None:
|
||||||
@ -466,14 +466,3 @@ def stack(*args, **kwds):
|
|||||||
except NameError:
|
except NameError:
|
||||||
consoles = [c]
|
consoles = [c]
|
||||||
return c
|
return c
|
||||||
|
|
||||||
|
|
||||||
def mkQApp():
|
|
||||||
global QAPP
|
|
||||||
inst = QtGui.QApplication.instance()
|
|
||||||
if inst is None:
|
|
||||||
QAPP = QtGui.QApplication([])
|
|
||||||
else:
|
|
||||||
QAPP = inst
|
|
||||||
return QAPP
|
|
||||||
|
|
||||||
|
@ -6,17 +6,11 @@ it is possible to place any widget into its own window by simply calling its
|
|||||||
show() method.
|
show() method.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from .Qt import QtCore, QtGui
|
from .Qt import QtCore, QtGui, mkQApp
|
||||||
from .widgets.PlotWidget import *
|
from .widgets.PlotWidget import *
|
||||||
from .imageview import *
|
from .imageview import *
|
||||||
from .widgets.GraphicsLayoutWidget import GraphicsLayoutWidget
|
from .widgets.GraphicsLayoutWidget import GraphicsLayoutWidget
|
||||||
from .widgets.GraphicsView import GraphicsView
|
from .widgets.GraphicsView import GraphicsView
|
||||||
QAPP = None
|
|
||||||
|
|
||||||
def mkQApp():
|
|
||||||
if QtGui.QApplication.instance() is None:
|
|
||||||
global QAPP
|
|
||||||
QAPP = QtGui.QApplication([])
|
|
||||||
|
|
||||||
|
|
||||||
class GraphicsWindow(GraphicsLayoutWidget):
|
class GraphicsWindow(GraphicsLayoutWidget):
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from ..Qt import QtGui
|
from ..Qt import QtGui, mkQApp
|
||||||
from ..graphicsItems.GraphicsLayout import GraphicsLayout
|
from ..graphicsItems.GraphicsLayout import GraphicsLayout
|
||||||
from .GraphicsView import GraphicsView
|
from .GraphicsView import GraphicsView
|
||||||
|
|
||||||
@ -48,6 +48,7 @@ class GraphicsLayoutWidget(GraphicsView):
|
|||||||
:func:`clear <pyqtgraph.GraphicsLayout.clear>`
|
:func:`clear <pyqtgraph.GraphicsLayout.clear>`
|
||||||
"""
|
"""
|
||||||
def __init__(self, parent=None, show=False, size=None, title=None, **kargs):
|
def __init__(self, parent=None, show=False, size=None, title=None, **kargs):
|
||||||
|
mkQApp()
|
||||||
GraphicsView.__init__(self, parent)
|
GraphicsView.__init__(self, parent)
|
||||||
self.ci = GraphicsLayout(**kargs)
|
self.ci = GraphicsLayout(**kargs)
|
||||||
for n in ['nextRow', 'nextCol', 'nextColumn', 'addPlot', 'addViewBox', 'addItem', 'getItem', 'addLayout', 'addLabel', 'removeItem', 'itemIndex', 'clear']:
|
for n in ['nextRow', 'nextCol', 'nextColumn', 'addPlot', 'addViewBox', 'addItem', 'getItem', 'addLayout', 'addLabel', 'removeItem', 'itemIndex', 'clear']:
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
## just import everything from sub-modules
|
|
||||||
|
|
||||||
#import os
|
|
||||||
|
|
||||||
#d = os.path.split(__file__)[0]
|
|
||||||
#files = []
|
|
||||||
#for f in os.listdir(d):
|
|
||||||
#if os.path.isdir(os.path.join(d, f)):
|
|
||||||
#files.append(f)
|
|
||||||
#elif f[-3:] == '.py' and f != '__init__.py':
|
|
||||||
#files.append(f[:-3])
|
|
||||||
|
|
||||||
#for modName in files:
|
|
||||||
#mod = __import__(modName, globals(), locals(), fromlist=['*'])
|
|
||||||
#if hasattr(mod, '__all__'):
|
|
||||||
#names = mod.__all__
|
|
||||||
#else:
|
|
||||||
#names = [n for n in dir(mod) if n[0] != '_']
|
|
||||||
#for k in names:
|
|
||||||
#print modName, k
|
|
||||||
#globals()[k] = getattr(mod, k)
|
|
Loading…
Reference in New Issue
Block a user