Is there a way to create a set of checkboxes in the GUI using vtkPythonAlgorithm decorators? Perhaps using xml?
Thanks. I found the dataarrayselection
property it in the PythonCSVReader
example. I kept looking for something with the words “checkbox” in it. For those who are curious, here’s my simple implementation, adapted from the PythonCSVReader
example.:
# Add this function to the top of your code, above the class definition
def createModifiedCallback(anobject):
import weakref
weakref_obj = weakref.ref(anobject)
anobject = None
def _markmodified(*args, **kwars):
o = weakref_obj()
if o is not None:
o.Modified()
return _markmodified
# add this code to the __init__ (self): function
from vtkmodules.vtkCommonCore import vtkDataArraySelection
self._arrayselection = vtkDataArraySelection()
self._arrayselection.AddObserver("ModifiedEvent", createModifiedCallback(self))
self._arrayselection.AddArray('One')
self._arrayselection.AddArray('Two')
# This is the checkbox property
@smproperty.dataarrayselection(name="Arrays")
def GetDataArraySelection(self):
return self._arrayselection
# We can access whether an array is checked or not with
self._arrayselection.ArrayIsEnabled('One') # boolean 1 or 0
self._arrayselection.ArrayIsEnabled('Two')