# Checkbox decorator in Python Plugin

**URL:** https://discourse.paraview.org/t/checkbox-decorator-in-python-plugin/7656
**Category:** Development
**Tags:** python
**Created:** [July 20, 2021, 9:01pm UTC](https://discourse.paraview.org/t/checkbox-decorator-in-python-plugin/7656 "2021-07-20T21:01:29Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Jared\_Blanchard](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jared_blanchard/32/7174_2.png) [@Jared\_Blanchard](https://discourse.paraview.org/u/Jared_Blanchard)
#### Post date: [July 20, 2021, 9:01pm UTC](https://discourse.paraview.org/t/checkbox-decorator-in-python-plugin/7656/1 "2021-07-20T21:01:29Z")

</div>

Is there a way to create a set of checkboxes in the GUI using vtkPythonAlgorithm decorators? Perhaps using xml?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [August 3, 2021, 8:21am UTC](https://discourse.paraview.org/t/checkbox-decorator-in-python-plugin/7656/2 "2021-08-03T08:21:02Z")

</div>

Yes, See Examples/Plugin/PythonAlgorithm

---

<div class="post-metadata">

### Author: ![Jared\_Blanchard](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jared_blanchard/32/7174_2.png) [@Jared\_Blanchard](https://discourse.paraview.org/u/Jared_Blanchard)
#### Post date: [August 3, 2021, 3:03pm UTC](https://discourse.paraview.org/t/checkbox-decorator-in-python-plugin/7656/3 "2021-08-03T15:03:42Z")

</div>

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.:

```auto
# 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

```

```auto
# 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')

```

```auto
# This is the checkbox property
    @smproperty.dataarrayselection(name="Arrays")
    def GetDataArraySelection(self):
        return self._arrayselection

```

```auto
# We can access whether an array is checked or not with
        self._arrayselection.ArrayIsEnabled('One') # boolean 1 or 0
        self._arrayselection.ArrayIsEnabled('Two')

```
