Detect when a markup node's visibility changes

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.

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

Thanks, that worked well.

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

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