Minor edits and fixes
This commit is contained in:
parent
7ada1ede4a
commit
cc93c7ba43
@ -1,4 +1,4 @@
|
|||||||
from PyQt4 import QtCore, QtGui
|
from pyqtgraph.Qt import QtCore, QtGui
|
||||||
|
|
||||||
class CmdInput(QtGui.QLineEdit):
|
class CmdInput(QtGui.QLineEdit):
|
||||||
|
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
|
|
||||||
from pyqtgraph.Qt import QtCore, QtGui
|
from pyqtgraph.Qt import QtCore, QtGui
|
||||||
import sys, re, os, time, traceback
|
import sys, re, os, time, traceback, subprocess
|
||||||
import pyqtgraph as pg
|
import pyqtgraph as pg
|
||||||
import template
|
import template
|
||||||
import pyqtgraph.exceptionHandling as exceptionHandling
|
import pyqtgraph.exceptionHandling as exceptionHandling
|
||||||
import pickle
|
import pickle
|
||||||
|
|
||||||
EDITOR = "pykate {fileName}:{lineNum}"
|
|
||||||
|
|
||||||
class ConsoleWidget(QtGui.QWidget):
|
class ConsoleWidget(QtGui.QWidget):
|
||||||
"""
|
"""
|
||||||
Widget displaying console output and accepting command input.
|
Widget displaying console output and accepting command input.
|
||||||
@ -258,7 +256,7 @@ class ConsoleWidget(QtGui.QWidget):
|
|||||||
tb = self.currentFrame()
|
tb = self.currentFrame()
|
||||||
lineNum = tb.tb_lineno
|
lineNum = tb.tb_lineno
|
||||||
fileName = tb.tb_frame.f_code.co_filename
|
fileName = tb.tb_frame.f_code.co_filename
|
||||||
os.system(EDITOR.format(fileName=fileName, lineNum=lineNum))
|
subprocess.Popen(EDITOR.format(fileName=fileName, lineNum=lineNum), shell=True)
|
||||||
|
|
||||||
|
|
||||||
def allExceptionsHandler(self, *args):
|
def allExceptionsHandler(self, *args):
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
## make this version of pyqtgraph importable before any others
|
## make this version of pyqtgraph importable before any others
|
||||||
import sys, os
|
import sys, os
|
||||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
|
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')))
|
||||||
|
@ -483,6 +483,8 @@ class AxisItem(GraphicsWidget):
|
|||||||
|
|
||||||
## determine size of this item in pixels
|
## determine size of this item in pixels
|
||||||
points = list(map(self.mapToDevice, span))
|
points = list(map(self.mapToDevice, span))
|
||||||
|
if None in points:
|
||||||
|
return
|
||||||
lengthInPixels = Point(points[1] - points[0]).length()
|
lengthInPixels = Point(points[1] - points[0]).length()
|
||||||
if lengthInPixels == 0:
|
if lengthInPixels == 0:
|
||||||
return
|
return
|
||||||
|
@ -226,6 +226,7 @@ class ScatterPlotItem(GraphicsObject):
|
|||||||
self.setPointData(kargs['data'], dataSet=newData)
|
self.setPointData(kargs['data'], dataSet=newData)
|
||||||
|
|
||||||
#self.updateSpots()
|
#self.updateSpots()
|
||||||
|
self.prepareGeometryChange()
|
||||||
self.bounds = [None, None]
|
self.bounds = [None, None]
|
||||||
self.generateSpotItems()
|
self.generateSpotItems()
|
||||||
self.sigPlotChanged.emit(self)
|
self.sigPlotChanged.emit(self)
|
||||||
@ -396,7 +397,7 @@ class ScatterPlotItem(GraphicsObject):
|
|||||||
if frac >= 1.0 and self.bounds[ax] is not None:
|
if frac >= 1.0 and self.bounds[ax] is not None:
|
||||||
return self.bounds[ax]
|
return self.bounds[ax]
|
||||||
|
|
||||||
self.prepareGeometryChange()
|
#self.prepareGeometryChange()
|
||||||
if self.data is None or len(self.data) == 0:
|
if self.data is None or len(self.data) == 0:
|
||||||
return (None, None)
|
return (None, None)
|
||||||
|
|
||||||
@ -464,6 +465,7 @@ class ScatterPlotItem(GraphicsObject):
|
|||||||
return QtCore.QRectF(xmn, ymn, xmx-xmn, ymx-ymn)
|
return QtCore.QRectF(xmn, ymn, xmx-xmn, ymx-ymn)
|
||||||
|
|
||||||
def viewRangeChanged(self):
|
def viewRangeChanged(self):
|
||||||
|
self.prepareGeometryChange()
|
||||||
GraphicsObject.viewRangeChanged(self)
|
GraphicsObject.viewRangeChanged(self)
|
||||||
self.bounds = [None, None]
|
self.bounds = [None, None]
|
||||||
|
|
||||||
|
@ -113,4 +113,6 @@ class ParameterTree(TreeWidget):
|
|||||||
sel[0].selected(True)
|
sel[0].selected(True)
|
||||||
return TreeWidget.selectionChanged(self, *args)
|
return TreeWidget.selectionChanged(self, *args)
|
||||||
|
|
||||||
|
def wheelEvent(self, ev):
|
||||||
|
self.clearSelection()
|
||||||
|
return TreeWidget.wheelEvent(self, ev)
|
||||||
|
@ -75,13 +75,10 @@ class GraphicsView(QtGui.QGraphicsView):
|
|||||||
self.setViewportUpdateMode(QtGui.QGraphicsView.MinimalViewportUpdate)
|
self.setViewportUpdateMode(QtGui.QGraphicsView.MinimalViewportUpdate)
|
||||||
|
|
||||||
|
|
||||||
#self.setSceneRect(QtCore.QRectF(-1e10, -1e10, 2e10, 2e10))
|
|
||||||
|
|
||||||
self.lockedViewports = []
|
self.lockedViewports = []
|
||||||
self.lastMousePos = None
|
self.lastMousePos = None
|
||||||
self.setMouseTracking(True)
|
self.setMouseTracking(True)
|
||||||
self.aspectLocked = False
|
self.aspectLocked = False
|
||||||
#self.yInverted = True
|
|
||||||
self.range = QtCore.QRectF(0, 0, 1, 1)
|
self.range = QtCore.QRectF(0, 0, 1, 1)
|
||||||
self.autoPixelRange = True
|
self.autoPixelRange = True
|
||||||
self.currentItem = None
|
self.currentItem = None
|
||||||
@ -101,15 +98,10 @@ class GraphicsView(QtGui.QGraphicsView):
|
|||||||
self.scaleCenter = False ## should scaling center around view center (True) or mouse click (False)
|
self.scaleCenter = False ## should scaling center around view center (True) or mouse click (False)
|
||||||
self.clickAccepted = False
|
self.clickAccepted = False
|
||||||
|
|
||||||
#def paintEvent(self, *args):
|
|
||||||
#prof = debug.Profiler('GraphicsView.paintEvent '+str(id(self)), disabled=False)
|
|
||||||
#QtGui.QGraphicsView.paintEvent(self, *args)
|
|
||||||
#prof.finish()
|
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self.centralWidget = None
|
self.centralWidget = None
|
||||||
self.scene().clear()
|
self.scene().clear()
|
||||||
#print " ", self.scene().itemCount()
|
|
||||||
self.currentItem = None
|
self.currentItem = None
|
||||||
self.sceneObj = None
|
self.sceneObj = None
|
||||||
self.closed = True
|
self.closed = True
|
||||||
@ -123,11 +115,9 @@ class GraphicsView(QtGui.QGraphicsView):
|
|||||||
else:
|
else:
|
||||||
v = QtGui.QWidget()
|
v = QtGui.QWidget()
|
||||||
|
|
||||||
#v.setStyleSheet("background-color: #000000;")
|
|
||||||
self.setViewport(v)
|
self.setViewport(v)
|
||||||
|
|
||||||
def keyPressEvent(self, ev):
|
def keyPressEvent(self, ev):
|
||||||
#QtGui.QGraphicsView.keyPressEvent(self, ev)
|
|
||||||
self.scene().keyPressEvent(ev) ## bypass view, hand event directly to scene
|
self.scene().keyPressEvent(ev) ## bypass view, hand event directly to scene
|
||||||
## (view likes to eat arrow key events)
|
## (view likes to eat arrow key events)
|
||||||
|
|
||||||
@ -196,11 +186,6 @@ class GraphicsView(QtGui.QGraphicsView):
|
|||||||
scale = [sx, sy]
|
scale = [sx, sy]
|
||||||
if self.aspectLocked:
|
if self.aspectLocked:
|
||||||
scale[0] = scale[1]
|
scale[0] = scale[1]
|
||||||
#adj = (self.range.width()*0.5*(1.0-(1.0/scale[0])), self.range.height()*0.5*(1.0-(1.0/scale[1])))
|
|
||||||
#print "======\n", scale, adj
|
|
||||||
#print self.range
|
|
||||||
#self.range.adjust(adj[0], adj[1], -adj[0], -adj[1])
|
|
||||||
#print self.range
|
|
||||||
|
|
||||||
if self.scaleCenter:
|
if self.scaleCenter:
|
||||||
center = None
|
center = None
|
||||||
@ -270,13 +255,6 @@ class GraphicsView(QtGui.QGraphicsView):
|
|||||||
r1.setBottom(r.bottom())
|
r1.setBottom(r.bottom())
|
||||||
GraphicsView.setRange(self, r1, padding=[0, padding], propagate=False)
|
GraphicsView.setRange(self, r1, padding=[0, padding], propagate=False)
|
||||||
|
|
||||||
#def invertY(self, invert=True):
|
|
||||||
##if self.yInverted != invert:
|
|
||||||
##self.scale[1] *= -1.
|
|
||||||
#self.yInverted = invert
|
|
||||||
#self.updateMatrix()
|
|
||||||
|
|
||||||
|
|
||||||
def wheelEvent(self, ev):
|
def wheelEvent(self, ev):
|
||||||
QtGui.QGraphicsView.wheelEvent(self, ev)
|
QtGui.QGraphicsView.wheelEvent(self, ev)
|
||||||
if not self.mouseEnabled:
|
if not self.mouseEnabled:
|
||||||
@ -289,40 +267,12 @@ class GraphicsView(QtGui.QGraphicsView):
|
|||||||
def setAspectLocked(self, s):
|
def setAspectLocked(self, s):
|
||||||
self.aspectLocked = s
|
self.aspectLocked = s
|
||||||
|
|
||||||
#def mouseDoubleClickEvent(self, ev):
|
|
||||||
#QtGui.QGraphicsView.mouseDoubleClickEvent(self, ev)
|
|
||||||
#pass
|
|
||||||
|
|
||||||
### This function is here because interactive mode is disabled due to bugs.
|
|
||||||
#def graphicsSceneEvent(self, ev, pev=None, fev=None):
|
|
||||||
#ev1 = GraphicsSceneMouseEvent()
|
|
||||||
#ev1.setPos(QtCore.QPointF(ev.pos().x(), ev.pos().y()))
|
|
||||||
#ev1.setButtons(ev.buttons())
|
|
||||||
#ev1.setButton(ev.button())
|
|
||||||
#ev1.setModifiers(ev.modifiers())
|
|
||||||
#ev1.setScenePos(self.mapToScene(QtCore.QPoint(ev.pos())))
|
|
||||||
#if pev is not None:
|
|
||||||
#ev1.setLastPos(pev.pos())
|
|
||||||
#ev1.setLastScenePos(pev.scenePos())
|
|
||||||
#ev1.setLastScreenPos(pev.screenPos())
|
|
||||||
#if fev is not None:
|
|
||||||
#ev1.setButtonDownPos(fev.pos())
|
|
||||||
#ev1.setButtonDownScenePos(fev.scenePos())
|
|
||||||
#ev1.setButtonDownScreenPos(fev.screenPos())
|
|
||||||
#return ev1
|
|
||||||
|
|
||||||
def leaveEvent(self, ev):
|
def leaveEvent(self, ev):
|
||||||
self.scene().leaveEvent(ev) ## inform scene when mouse leaves
|
self.scene().leaveEvent(ev) ## inform scene when mouse leaves
|
||||||
|
|
||||||
def mousePressEvent(self, ev):
|
def mousePressEvent(self, ev):
|
||||||
QtGui.QGraphicsView.mousePressEvent(self, ev)
|
QtGui.QGraphicsView.mousePressEvent(self, ev)
|
||||||
|
|
||||||
#print "Press over:"
|
|
||||||
#for i in self.items(ev.pos()):
|
|
||||||
# print i.zValue(), int(i.acceptedMouseButtons()), i, i.scenePos()
|
|
||||||
#print "Event accepted:", ev.isAccepted()
|
|
||||||
#print "Grabber:", self.scene().mouseGrabberItem()
|
|
||||||
|
|
||||||
|
|
||||||
if not self.mouseEnabled:
|
if not self.mouseEnabled:
|
||||||
return
|
return
|
||||||
@ -333,39 +283,14 @@ class GraphicsView(QtGui.QGraphicsView):
|
|||||||
self.scene().clearSelection()
|
self.scene().clearSelection()
|
||||||
return ## Everything below disabled for now..
|
return ## Everything below disabled for now..
|
||||||
|
|
||||||
#self.currentItem = None
|
|
||||||
#maxZ = None
|
|
||||||
#for i in self.items(ev.pos()):
|
|
||||||
#if maxZ is None or maxZ < i.zValue():
|
|
||||||
#self.currentItem = i
|
|
||||||
#maxZ = i.zValue()
|
|
||||||
#print "make event"
|
|
||||||
#self.pev = self.graphicsSceneEvent(ev)
|
|
||||||
#self.fev = self.pev
|
|
||||||
#if self.currentItem is not None:
|
|
||||||
#self.currentItem.mousePressEvent(self.pev)
|
|
||||||
##self.clearMouse()
|
|
||||||
##self.mouseTrail.append(Point(self.mapToScene(ev.pos())))
|
|
||||||
#self.emit(QtCore.SIGNAL("mousePressed(PyQt_PyObject)"), self.mouseTrail)
|
|
||||||
|
|
||||||
def mouseReleaseEvent(self, ev):
|
def mouseReleaseEvent(self, ev):
|
||||||
QtGui.QGraphicsView.mouseReleaseEvent(self, ev)
|
QtGui.QGraphicsView.mouseReleaseEvent(self, ev)
|
||||||
if not self.mouseEnabled:
|
if not self.mouseEnabled:
|
||||||
return
|
return
|
||||||
#self.mouseTrail.append(Point(self.mapToScene(ev.pos())))
|
|
||||||
#self.emit(QtCore.SIGNAL("mouseReleased"), ev)
|
|
||||||
self.sigMouseReleased.emit(ev)
|
self.sigMouseReleased.emit(ev)
|
||||||
self.lastButtonReleased = ev.button()
|
self.lastButtonReleased = ev.button()
|
||||||
return ## Everything below disabled for now..
|
return ## Everything below disabled for now..
|
||||||
|
|
||||||
##self.mouseTrail.append(Point(self.mapToScene(ev.pos())))
|
|
||||||
#self.emit(QtCore.SIGNAL("mouseReleased(PyQt_PyObject)"), self.mouseTrail)
|
|
||||||
#if self.currentItem is not None:
|
|
||||||
#pev = self.graphicsSceneEvent(ev, self.pev, self.fev)
|
|
||||||
#self.pev = pev
|
|
||||||
#self.currentItem.mouseReleaseEvent(pev)
|
|
||||||
#self.currentItem = None
|
|
||||||
|
|
||||||
def mouseMoveEvent(self, ev):
|
def mouseMoveEvent(self, ev):
|
||||||
if self.lastMousePos is None:
|
if self.lastMousePos is None:
|
||||||
self.lastMousePos = Point(ev.pos())
|
self.lastMousePos = Point(ev.pos())
|
||||||
@ -375,10 +300,7 @@ class GraphicsView(QtGui.QGraphicsView):
|
|||||||
QtGui.QGraphicsView.mouseMoveEvent(self, ev)
|
QtGui.QGraphicsView.mouseMoveEvent(self, ev)
|
||||||
if not self.mouseEnabled:
|
if not self.mouseEnabled:
|
||||||
return
|
return
|
||||||
#self.emit(QtCore.SIGNAL("sceneMouseMoved(PyQt_PyObject)"), self.mapToScene(ev.pos()))
|
|
||||||
self.sigSceneMouseMoved.emit(self.mapToScene(ev.pos()))
|
self.sigSceneMouseMoved.emit(self.mapToScene(ev.pos()))
|
||||||
#print "moved. Grabber:", self.scene().mouseGrabberItem()
|
|
||||||
|
|
||||||
|
|
||||||
if self.clickAccepted: ## Ignore event if an item in the scene has already claimed it.
|
if self.clickAccepted: ## Ignore event if an item in the scene has already claimed it.
|
||||||
return
|
return
|
||||||
@ -386,10 +308,7 @@ class GraphicsView(QtGui.QGraphicsView):
|
|||||||
if ev.buttons() == QtCore.Qt.RightButton:
|
if ev.buttons() == QtCore.Qt.RightButton:
|
||||||
delta = Point(np.clip(delta[0], -50, 50), np.clip(-delta[1], -50, 50))
|
delta = Point(np.clip(delta[0], -50, 50), np.clip(-delta[1], -50, 50))
|
||||||
scale = 1.01 ** delta
|
scale = 1.01 ** delta
|
||||||
#if self.yInverted:
|
|
||||||
#scale[0] = 1. / scale[0]
|
|
||||||
self.scale(scale[0], scale[1], center=self.mapToScene(self.mousePressPos))
|
self.scale(scale[0], scale[1], center=self.mapToScene(self.mousePressPos))
|
||||||
#self.emit(QtCore.SIGNAL('regionChanged(QRectF)'), self.range)
|
|
||||||
self.sigRangeChanged.emit(self, self.range)
|
self.sigRangeChanged.emit(self, self.range)
|
||||||
|
|
||||||
elif ev.buttons() in [QtCore.Qt.MidButton, QtCore.Qt.LeftButton]: ## Allow panning by left or mid button.
|
elif ev.buttons() in [QtCore.Qt.MidButton, QtCore.Qt.LeftButton]: ## Allow panning by left or mid button.
|
||||||
@ -397,23 +316,8 @@ class GraphicsView(QtGui.QGraphicsView):
|
|||||||
tr = -delta * px
|
tr = -delta * px
|
||||||
|
|
||||||
self.translate(tr[0], tr[1])
|
self.translate(tr[0], tr[1])
|
||||||
#self.emit(QtCore.SIGNAL('regionChanged(QRectF)'), self.range)
|
|
||||||
self.sigRangeChanged.emit(self, self.range)
|
self.sigRangeChanged.emit(self, self.range)
|
||||||
|
|
||||||
#return ## Everything below disabled for now..
|
|
||||||
|
|
||||||
##self.mouseTrail.append(Point(self.mapToScene(ev.pos())))
|
|
||||||
#if self.currentItem is not None:
|
|
||||||
#pev = self.graphicsSceneEvent(ev, self.pev, self.fev)
|
|
||||||
#self.pev = pev
|
|
||||||
#self.currentItem.mouseMoveEvent(pev)
|
|
||||||
|
|
||||||
#def paintEvent(self, ev):
|
|
||||||
#prof = debug.Profiler('GraphicsView.paintEvent (0x%x)' % id(self))
|
|
||||||
#QtGui.QGraphicsView.paintEvent(self, ev)
|
|
||||||
#prof.finish()
|
|
||||||
|
|
||||||
|
|
||||||
def pixelSize(self):
|
def pixelSize(self):
|
||||||
"""Return vector with the length and width of one view pixel in scene coordinates"""
|
"""Return vector with the length and width of one view pixel in scene coordinates"""
|
||||||
p0 = Point(0,0)
|
p0 = Point(0,0)
|
||||||
@ -423,80 +327,7 @@ class GraphicsView(QtGui.QGraphicsView):
|
|||||||
p11 = tr.map(p1)
|
p11 = tr.map(p1)
|
||||||
return Point(p11 - p01)
|
return Point(p11 - p01)
|
||||||
|
|
||||||
|
|
||||||
#def writeSvg(self, fileName=None):
|
|
||||||
#if fileName is None:
|
|
||||||
#self.fileDialog = FileDialog()
|
|
||||||
#self.fileDialog.setFileMode(QtGui.QFileDialog.AnyFile)
|
|
||||||
#self.fileDialog.setAcceptMode(QtGui.QFileDialog.AcceptSave)
|
|
||||||
#if GraphicsView.lastFileDir is not None:
|
|
||||||
#self.fileDialog.setDirectory(GraphicsView.lastFileDir)
|
|
||||||
#self.fileDialog.show()
|
|
||||||
#self.fileDialog.fileSelected.connect(self.writeSvg)
|
|
||||||
#return
|
|
||||||
#fileName = str(fileName)
|
|
||||||
#GraphicsView.lastFileDir = os.path.split(fileName)[0]
|
|
||||||
#self.svg = QtSvg.QSvgGenerator()
|
|
||||||
#self.svg.setFileName(fileName)
|
|
||||||
#self.svg.setSize(self.size())
|
|
||||||
#self.svg.setResolution(600)
|
|
||||||
#painter = QtGui.QPainter(self.svg)
|
|
||||||
#self.render(painter)
|
|
||||||
|
|
||||||
#def writeImage(self, fileName=None):
|
|
||||||
#if fileName is None:
|
|
||||||
#self.fileDialog = FileDialog()
|
|
||||||
#self.fileDialog.setFileMode(QtGui.QFileDialog.AnyFile)
|
|
||||||
#self.fileDialog.setAcceptMode(QtGui.QFileDialog.AcceptSave) ## this is the line that makes the fileDialog not show on mac
|
|
||||||
#if GraphicsView.lastFileDir is not None:
|
|
||||||
#self.fileDialog.setDirectory(GraphicsView.lastFileDir)
|
|
||||||
#self.fileDialog.show()
|
|
||||||
#self.fileDialog.fileSelected.connect(self.writeImage)
|
|
||||||
#return
|
|
||||||
#fileName = str(fileName)
|
|
||||||
#GraphicsView.lastFileDir = os.path.split(fileName)[0]
|
|
||||||
#self.png = QtGui.QImage(self.size(), QtGui.QImage.Format_ARGB32)
|
|
||||||
#painter = QtGui.QPainter(self.png)
|
|
||||||
#rh = self.renderHints()
|
|
||||||
#self.setRenderHints(QtGui.QPainter.Antialiasing)
|
|
||||||
#self.render(painter)
|
|
||||||
#self.setRenderHints(rh)
|
|
||||||
#self.png.save(fileName)
|
|
||||||
|
|
||||||
#def writePs(self, fileName=None):
|
|
||||||
#if fileName is None:
|
|
||||||
#self.fileDialog = FileDialog()
|
|
||||||
#self.fileDialog.setFileMode(QtGui.QFileDialog.AnyFile)
|
|
||||||
#self.fileDialog.setAcceptMode(QtGui.QFileDialog.AcceptSave)
|
|
||||||
#self.fileDialog.show()
|
|
||||||
#self.fileDialog.fileSelected.connect(self.writePs)
|
|
||||||
#return
|
|
||||||
##if fileName is None:
|
|
||||||
## fileName = str(QtGui.QFileDialog.getSaveFileName())
|
|
||||||
#printer = QtGui.QPrinter(QtGui.QPrinter.HighResolution)
|
|
||||||
#printer.setOutputFileName(fileName)
|
|
||||||
#painter = QtGui.QPainter(printer)
|
|
||||||
#self.render(painter)
|
|
||||||
#painter.end()
|
|
||||||
|
|
||||||
def dragEnterEvent(self, ev):
|
def dragEnterEvent(self, ev):
|
||||||
ev.ignore() ## not sure why, but for some reason this class likes to consume drag events
|
ev.ignore() ## not sure why, but for some reason this class likes to consume drag events
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#def getFreehandLine(self):
|
|
||||||
|
|
||||||
## Wait for click
|
|
||||||
#self.clearMouse()
|
|
||||||
#while self.lastButtonReleased != QtCore.Qt.LeftButton:
|
|
||||||
#QtGui.qApp.sendPostedEvents()
|
|
||||||
#QtGui.qApp.processEvents()
|
|
||||||
#time.sleep(0.01)
|
|
||||||
#fl = vstack(self.mouseTrail)
|
|
||||||
#return fl
|
|
||||||
|
|
||||||
#def getClick(self):
|
|
||||||
#fl = self.getFreehandLine()
|
|
||||||
#return fl[-1]
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ class ProgressDialog(QtGui.QProgressDialog):
|
|||||||
if dlg.wasCanceled():
|
if dlg.wasCanceled():
|
||||||
raise Exception("Processing canceled by user")
|
raise Exception("Processing canceled by user")
|
||||||
"""
|
"""
|
||||||
def __init__(self, labelText, minimum=0, maximum=100, cancelText='Cancel', parent=None, wait=250, busyCursor=False):
|
def __init__(self, labelText, minimum=0, maximum=100, cancelText='Cancel', parent=None, wait=250, busyCursor=False, disable=False):
|
||||||
"""
|
"""
|
||||||
============== ================================================================
|
============== ================================================================
|
||||||
**Arguments:**
|
**Arguments:**
|
||||||
@ -25,16 +25,17 @@ class ProgressDialog(QtGui.QProgressDialog):
|
|||||||
parent
|
parent
|
||||||
wait Length of time (im ms) to wait before displaying dialog
|
wait Length of time (im ms) to wait before displaying dialog
|
||||||
busyCursor If True, show busy cursor until dialog finishes
|
busyCursor If True, show busy cursor until dialog finishes
|
||||||
|
disable If True, the progress dialog will not be displayed
|
||||||
|
and calls to wasCanceled() will always return False.
|
||||||
|
If ProgressDialog is entered from a non-gui thread, it will
|
||||||
|
always be disabled.
|
||||||
============== ================================================================
|
============== ================================================================
|
||||||
"""
|
"""
|
||||||
|
|
||||||
isGuiThread = QtCore.QThread.currentThread() == QtCore.QCoreApplication.instance().thread()
|
isGuiThread = QtCore.QThread.currentThread() == QtCore.QCoreApplication.instance().thread()
|
||||||
if not isGuiThread:
|
self.disabled = disable or (not isGuiThread)
|
||||||
self.disabled = True
|
if self.disabled:
|
||||||
return
|
return
|
||||||
|
|
||||||
self.disabled = False
|
|
||||||
|
|
||||||
noCancel = False
|
noCancel = False
|
||||||
if cancelText is None:
|
if cancelText is None:
|
||||||
cancelText = ''
|
cancelText = ''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user