diff --git a/dockarea/DockArea.py b/dockarea/DockArea.py index d49f02ad..78d512f3 100644 --- a/dockarea/DockArea.py +++ b/dockarea/DockArea.py @@ -208,6 +208,10 @@ class DockArea(Container, QtGui.QWidget, DockDrop): def restoreState(self, state): """ Restore Dock configuration as generated by saveState. + + Note that this function does not create any Docks--it will only + restore the arrangement of an existing set of Docks. + """ ## 1) make dict of all docks and list of existing containers @@ -240,8 +244,11 @@ class DockArea(Container, QtGui.QWidget, DockDrop): typ, contents, state = state pfx = " " * depth if typ == 'dock': - obj = docks[contents] - del docks[contents] + try: + obj = docks[contents] + del docks[contents] + except KeyError: + raise Exception('Cannot restore dock state; no dock with name "%s"' % contents) else: obj = self.makeContainer(typ) @@ -270,7 +277,7 @@ class DockArea(Container, QtGui.QWidget, DockDrop): if isinstance(obj, Dock): d[obj.name()] = obj - else: + elif obj is not None: c.append(obj) for i in range(obj.count()): o2 = obj.widget(i) diff --git a/graphicsItems/GradientEditorItem.py b/graphicsItems/GradientEditorItem.py index 33970d2c..3c078ede 100644 --- a/graphicsItems/GradientEditorItem.py +++ b/graphicsItems/GradientEditorItem.py @@ -165,6 +165,9 @@ class TickSliderItem(GraphicsWidget): tick.setPos(pos) self.ticks[tick] = float(newX) / self.length + def tickMoveFinished(self, tick): + pass + def tickClicked(self, tick, ev): if ev.button() == QtCore.Qt.RightButton: self.removeTick(tick) @@ -340,16 +343,18 @@ class GradientEditorItem(TickSliderItem): customizable by the user. :class: `GradientWidget ` provides a widget with a GradientEditorItem that can be added to a GUI. - ======================== =========================================================== + ================================ =========================================================== **Signals** - sigGradientChanged(self) Signal is emitted anytime the gradient changes. The signal - is emitted in real time while ticks are being dragged or - colors are being changed. - ======================== =========================================================== + sigGradientChanged(self) Signal is emitted anytime the gradient changes. The signal + is emitted in real time while ticks are being dragged or + colors are being changed. + sigGradientChangeFinished(self) Signal is emitted when the gradient is finished changing. + ================================ =========================================================== """ sigGradientChanged = QtCore.Signal(object) + sigGradientChangeFinished = QtCore.Signal(object) def __init__(self, *args, **kargs): """ @@ -381,6 +386,7 @@ class GradientEditorItem(TickSliderItem): self.colorDialog.currentColorChanged.connect(self.currentColorChanged) self.colorDialog.rejected.connect(self.currentColorRejected) + self.colorDialog.accepted.connect(self.currentColorAccepted) self.backgroundRect.setParentItem(self) self.gradRect.setParentItem(self) @@ -508,6 +514,9 @@ class GradientEditorItem(TickSliderItem): self.setTickColor(self.currentTick, self.currentTickColor) self.updateGradient() + def currentColorAccepted(self): + self.sigGradientChangeFinished.emit(self) + def tickClicked(self, tick, ev): #private if ev.button() == QtCore.Qt.LeftButton: @@ -533,6 +542,9 @@ class GradientEditorItem(TickSliderItem): TickSliderItem.tickMoved(self, tick, pos) self.updateGradient() + def tickMoveFinished(self, tick): + self.sigGradientChangeFinished.emit(self) + def getGradient(self): """Return a QLinearGradient object.""" @@ -669,7 +681,7 @@ class GradientEditorItem(TickSliderItem): TickSliderItem.mouseReleaseEvent(self, ev) self.updateGradient() - def addTick(self, x, color=None, movable=True): + def addTick(self, x, color=None, movable=True, finish=True): """ Add a tick to the gradient. Return the tick. @@ -688,7 +700,17 @@ class GradientEditorItem(TickSliderItem): t = TickSliderItem.addTick(self, x, color=color, movable=movable) t.colorChangeAllowed = True t.removeAllowed = True + + if finish: + self.sigGradientChangeFinished.emit(self) return t + + + def removeTick(self, tick, finish=True): + TickSliderItem.removeTick(self, tick) + if finish: + self.sigGradientChangeFinished.emit(self) + def saveState(self): """ @@ -723,13 +745,14 @@ class GradientEditorItem(TickSliderItem): ## public self.setColorMode(state['mode']) for t in list(self.ticks.keys()): - self.removeTick(t) + self.removeTick(t, finish=False) for t in state['ticks']: c = QtGui.QColor(*t[1]) - self.addTick(t[0], c) + self.addTick(t[0], c, finish=False) self.updateGradient() + self.sigGradientChangeFinished.emit(self) - + class Tick(GraphicsObject): ## private class @@ -791,6 +814,7 @@ class Tick(GraphicsObject): if ev.isFinish(): self.moving = False self.sigMoved.emit(self) + self.view().tickMoveFinished(self) def mouseClickEvent(self, ev): if ev.button() == QtCore.Qt.RightButton and self.moving: diff --git a/graphicsItems/PlotDataItem.py b/graphicsItems/PlotDataItem.py index 34af641a..ce5b11aa 100644 --- a/graphicsItems/PlotDataItem.py +++ b/graphicsItems/PlotDataItem.py @@ -361,9 +361,11 @@ class PlotDataItem(GraphicsObject): self.updateItems() prof.mark('update items') + view = self.getViewBox() if view is not None: view.itemBoundsChanged(self) ## inform view so it can update its range if it wants + self.sigPlotChanged.emit(self) prof.mark('emit') prof.finish() diff --git a/graphicsItems/PlotItem/PlotItem.py b/graphicsItems/PlotItem/PlotItem.py index 46bc4d5b..3177a176 100644 --- a/graphicsItems/PlotItem/PlotItem.py +++ b/graphicsItems/PlotItem/PlotItem.py @@ -506,12 +506,14 @@ class PlotItem(GraphicsWidget): self.curves.append(item) #self.addItem(c) + if hasattr(item, 'setLogMode'): + item.setLogMode(self.ctrl.logXCheck.isChecked(), self.ctrl.logYCheck.isChecked()) + if isinstance(item, PlotDataItem): ## configure curve for this plot (alpha, auto) = self.alphaState() item.setAlpha(alpha, auto) item.setFftMode(self.ctrl.fftCheck.isChecked()) - item.setLogMode(self.ctrl.logXCheck.isChecked(), self.ctrl.logYCheck.isChecked()) item.setDownsampling(self.downsampleMode()) item.setPointMode(self.pointMode()) @@ -526,6 +528,7 @@ class PlotItem(GraphicsWidget): #c.connect(c, QtCore.SIGNAL('plotChanged'), self.plotChanged) #item.sigPlotChanged.connect(self.plotChanged) #self.plotChanged() + def addDataItem(self, item, *args): print("PlotItem.addDataItem is deprecated. Use addItem instead.") @@ -878,8 +881,9 @@ class PlotItem(GraphicsWidget): def updateLogMode(self): x = self.ctrl.logXCheck.isChecked() y = self.ctrl.logYCheck.isChecked() - for c in self.curves: - c.setLogMode(x,y) + for i in self.items: + if hasattr(i, 'setLogMode'): + i.setLogMode(x,y) self.getAxis('bottom').setLogMode(x) self.getAxis('top').setLogMode(x) self.getAxis('left').setLogMode(y) diff --git a/parametertree/parameterTypes.py b/parametertree/parameterTypes.py index 315081ce..3aab5a6d 100644 --- a/parametertree/parameterTypes.py +++ b/parametertree/parameterTypes.py @@ -516,6 +516,7 @@ class ListParameter(Parameter): if opts.get('limits', None) is None: opts['limits'] = [] Parameter.__init__(self, **opts) + self.setLimits(opts['limits']) def setLimits(self, limits): self.forward, self.reverse = self.mapping(limits) diff --git a/widgets/GradientWidget.py b/widgets/GradientWidget.py index ecf3f585..2b9b52d2 100644 --- a/widgets/GradientWidget.py +++ b/widgets/GradientWidget.py @@ -11,6 +11,7 @@ __all__ = ['TickSlider', 'GradientWidget', 'BlackWhiteSlider'] class GradientWidget(GraphicsView): sigGradientChanged = QtCore.Signal(object) + sigGradientChangeFinished = QtCore.Signal(object) def __init__(self, parent=None, orientation='bottom', *args, **kargs): GraphicsView.__init__(self, parent, useOpenGL=False, background=None) @@ -18,6 +19,7 @@ class GradientWidget(GraphicsView): kargs['tickPen'] = 'k' self.item = GradientEditorItem(*args, **kargs) self.item.sigGradientChanged.connect(self.sigGradientChanged) + self.item.sigGradientChangeFinished.connect(self.sigGradientChangeFinished) self.setCentralItem(self.item) self.setOrientation(orientation) self.setCacheMode(self.CacheNone) diff --git a/widgets/TreeWidget.py b/widgets/TreeWidget.py index ef2f1ec9..97fbe953 100644 --- a/widgets/TreeWidget.py +++ b/widgets/TreeWidget.py @@ -201,8 +201,10 @@ class TreeWidget(QtGui.QTreeWidget): for item in items: self.prepareMove(item) QtGui.QTreeWidget.clear(self) - for item in items: - self.informTreeWidgetChange(item) + + ## Why do we want to do this? It causes RuntimeErrors. + #for item in items: + #self.informTreeWidgetChange(item) class TreeWidgetItem(QtGui.QTreeWidgetItem):