Minor updates:
GraphicsObject - corrected bug in viewPos() method WidgetGroup - allow bound methods in interfaces parametertree - fixed crash when calling remove from context menu
This commit is contained in:
parent
f80b73b173
commit
48929a2aa6
@ -255,7 +255,14 @@ class WidgetGroup(QtCore.QObject):
|
|||||||
if getFunc is None:
|
if getFunc is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
val = getFunc(w)
|
## if the getter function provided in the interface is a bound method,
|
||||||
|
## then just call the method directly. Otherwise, pass in the widget as the first arg
|
||||||
|
## to the function.
|
||||||
|
if inspect.ismethod(getFunc) and getFunc.im_self is not None:
|
||||||
|
val = getFunc()
|
||||||
|
else:
|
||||||
|
val = getFunc(w)
|
||||||
|
|
||||||
if self.scales[w] is not None:
|
if self.scales[w] is not None:
|
||||||
val /= self.scales[w]
|
val /= self.scales[w]
|
||||||
#if isinstance(val, QtCore.QString):
|
#if isinstance(val, QtCore.QString):
|
||||||
@ -273,7 +280,15 @@ class WidgetGroup(QtCore.QObject):
|
|||||||
setFunc = WidgetGroup.classes[type(w)][2]
|
setFunc = WidgetGroup.classes[type(w)][2]
|
||||||
else:
|
else:
|
||||||
setFunc = w.widgetGroupInterface()[2]
|
setFunc = w.widgetGroupInterface()[2]
|
||||||
setFunc(w, v)
|
|
||||||
|
## if the setter function provided in the interface is a bound method,
|
||||||
|
## then just call the method directly. Otherwise, pass in the widget as the first arg
|
||||||
|
## to the function.
|
||||||
|
if inspect.ismethod(setFunc) and setFunc.im_self is not None:
|
||||||
|
setFunc(v)
|
||||||
|
else:
|
||||||
|
setFunc(w, v)
|
||||||
|
|
||||||
#name = self.widgetList[w]
|
#name = self.widgetList[w]
|
||||||
#if name in self.cache and (self.cache[name] != v1):
|
#if name in self.cache and (self.cache[name] != v1):
|
||||||
#print "%s: Cached value %s != set value %s" % (name, str(self.cache[name]), str(v1))
|
#print "%s: Cached value %s != set value %s" % (name, str(self.cache[name]), str(v1))
|
||||||
|
@ -229,7 +229,7 @@ class GraphicsItemMethods(object):
|
|||||||
return Point(QtGui.QGraphicsObject.pos(self))
|
return Point(QtGui.QGraphicsObject.pos(self))
|
||||||
|
|
||||||
def viewPos(self):
|
def viewPos(self):
|
||||||
return self.mapToView(self.pos())
|
return self.mapToView(self.mapFromParent(self.pos()))
|
||||||
|
|
||||||
#def itemChange(self, change, value):
|
#def itemChange(self, change, value):
|
||||||
#ret = QtGui.QGraphicsObject.itemChange(self, change, value)
|
#ret = QtGui.QGraphicsObject.itemChange(self, change, value)
|
||||||
|
@ -284,6 +284,10 @@ class Parameter(QtCore.QObject):
|
|||||||
for ch in self.childs[:]:
|
for ch in self.childs[:]:
|
||||||
self.removeChild(ch)
|
self.removeChild(ch)
|
||||||
|
|
||||||
|
def children(self):
|
||||||
|
## warning -- this overrides QObject.children
|
||||||
|
return self.childs[:]
|
||||||
|
|
||||||
def parentChanged(self, parent):
|
def parentChanged(self, parent):
|
||||||
self._parent = parent
|
self._parent = parent
|
||||||
self.sigParentChanged.emit(self, parent)
|
self.sigParentChanged.emit(self, parent)
|
||||||
|
@ -38,7 +38,7 @@ class ParameterItem(QtGui.QTreeWidgetItem):
|
|||||||
flags |= QtCore.Qt.ItemIsEditable
|
flags |= QtCore.Qt.ItemIsEditable
|
||||||
self.contextMenu.addAction('Rename').triggered.connect(self.editName)
|
self.contextMenu.addAction('Rename').triggered.connect(self.editName)
|
||||||
if opts.get('removable', False):
|
if opts.get('removable', False):
|
||||||
self.contextMenu.addAction("Remove").triggered.connect(self.param.remove)
|
self.contextMenu.addAction("Remove").triggered.connect(self.requestRemove)
|
||||||
|
|
||||||
## handle movable / dropEnabled options
|
## handle movable / dropEnabled options
|
||||||
if opts.get('movable', False):
|
if opts.get('movable', False):
|
||||||
@ -144,5 +144,9 @@ class ParameterItem(QtGui.QTreeWidgetItem):
|
|||||||
"""Called when this item has been selected (sel=True) OR deselected (sel=False)"""
|
"""Called when this item has been selected (sel=True) OR deselected (sel=False)"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def requestRemove(self):
|
||||||
|
## called when remove is selected from the context menu.
|
||||||
|
## we need to delay removal until the action is complete
|
||||||
|
## since destroying the menu in mid-action will cause a crash.
|
||||||
|
QtCore.QTimer.singleShot(0, self.param.remove)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user