# Detect when a markup node's visibility changes

**URL:** https://discourse.slicer.org/t/detect-when-a-markup-nodes-visibility-changes/31580
**Category:** Support
**Created:** [September 6, 2023, 1:23am UTC](https://discourse.slicer.org/t/detect-when-a-markup-nodes-visibility-changes/31580 "2023-09-06T01:23:23Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![bruce](https://avatars.discourse-cdn.com/v4/letter/b/ccd318/32.png) [@bruce](https://discourse.slicer.org/u/bruce)
#### Post date: [September 6, 2023, 1:23am UTC](https://discourse.slicer.org/t/detect-when-a-markup-nodes-visibility-changes/31580/1 "2023-09-06T01:23:23Z")

</div>

I have a Python loadable scriptable module that creates a custom workflow. The module contains tables of nodes (such as MarkupsROINodes and MarkupsLineNodes) and provides a checkbox for the user to change their visibiliity.

I am observing these nodes using node.AddObserver(vtk.vtkCommand.ModifiedEvent, myCallback) to detect if they have been deleted so they can be removed them from the module’s table. How do I observe their visibility status (in case it has been changed through another menu)? I tried node.AddObserver(vtk.vtkMRMLDisplayableNode.DisplayModifiedEvent, myCallback) but this didn’t seem to pick up any events.

---

<div class="post-metadata">

### Author: ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)
#### Post date: [September 6, 2023, 7:01pm UTC](https://discourse.slicer.org/t/detect-when-a-markup-nodes-visibility-changes/31580/2 "2023-09-06T19:01:50Z")

</div>

Visibility is stored in the display node, so you need to add the observer to that node, not the markup node.

---

<div class="post-metadata">

### Author: ![bruce](https://avatars.discourse-cdn.com/v4/letter/b/ccd318/32.png) [@bruce](https://discourse.slicer.org/u/bruce)
#### Post date: [September 6, 2023, 9:14pm UTC](https://discourse.slicer.org/t/detect-when-a-markup-nodes-visibility-changes/31580/3 "2023-09-06T21:14:46Z")

</div>

Thanks, that worked well.

> ```
> node.GetDisplayNode().AddObserver(vtk.vtkCommand.ModifiedEvent, myCallback)
> 
> ```

---

<div class="post-metadata">

### Author: ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)
#### Post date: [September 7, 2023, 11:15am UTC](https://discourse.slicer.org/t/detect-when-a-markup-nodes-visibility-changes/31580/4 "2023-09-07T11:15:16Z")

</div>

Or  
`node.AddObserver(slicer.vtkMRMLDisplayableNode.DisplayModifiedEvent, myCallback)`
