Merge pull request #1218 from campagnola/ptree-fix

Fix ParameterTree.clear()
This commit is contained in:
Ogi Moore 2020-05-30 13:00:10 -07:00 committed by GitHub
commit 03b8385e62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -426,10 +426,13 @@ class GroupParameterItem(ParameterItem):
def treeWidgetChanged(self): def treeWidgetChanged(self):
ParameterItem.treeWidgetChanged(self) ParameterItem.treeWidgetChanged(self)
self.treeWidget().setFirstItemColumnSpanned(self, True) tw = self.treeWidget()
if tw is None:
return
tw.setFirstItemColumnSpanned(self, True)
if self.addItem is not None: if self.addItem is not None:
self.treeWidget().setItemWidget(self.addItem, 0, self.addWidgetBox) tw.setItemWidget(self.addItem, 0, self.addWidgetBox)
self.treeWidget().setFirstItemColumnSpanned(self.addItem, True) tw.setFirstItemColumnSpanned(self.addItem, True)
def addChild(self, child): ## make sure added childs are actually inserted before add btn def addChild(self, child): ## make sure added childs are actually inserted before add btn
if self.addItem is not None: if self.addItem is not None:
@ -664,8 +667,12 @@ class TextParameterItem(WidgetParameterItem):
## TODO: fix so that superclass method can be called ## TODO: fix so that superclass method can be called
## (WidgetParameter should just natively support this style) ## (WidgetParameter should just natively support this style)
#WidgetParameterItem.treeWidgetChanged(self) #WidgetParameterItem.treeWidgetChanged(self)
self.treeWidget().setFirstItemColumnSpanned(self.subItem, True) tw = self.treeWidget()
self.treeWidget().setItemWidget(self.subItem, 0, self.textBox) if tw is None:
return
tw.setFirstItemColumnSpanned(self.subItem, True)
tw.setItemWidget(self.subItem, 0, self.textBox)
# for now, these are copied from ParameterItem.treeWidgetChanged # for now, these are copied from ParameterItem.treeWidgetChanged
self.setHidden(not self.param.opts.get('visible', True)) self.setHidden(not self.param.opts.get('visible', True))