[slicer-users] Syncing widgets with MRML scene

Ali Uneri ali.uneri at jhu.edu
Fri Mar 19 14:40:03 EDT 2010


Hello,

This mail-list has been very helpful in the past, and I'm in need of help
once again.

I'm having a problem with my Slicer Interactive module in Python. I've
created a vtkSlicerNodeSelectorWidget and I want the nodes to be in sync
with my MRMLScene, i.e. if the nodes are of type vtkMRMLFiducialListNode, I
would like to see them in my widget just as in the Fiducials Module. Below
is how I currently instantiate my widget:

from Slicer import slicer

class MyModule(ScriptedModuleGUI):
   ...

   self.my_selector = slicer.vtkSlicerNodeSelectorWidget()
   self.my_selector.SetParent(parent_frame)
   self.my_selector.SetNodeClass('vtkMRMLFiducialListNode', 0, 0, 0)
   self.my_selector.Create()
   self.my_selector.SetMRMLScene(slicer.MRMLScene)
   self.my_selector.UpdateMenu()
   self.my_selector.SetLabelText('My Fiducials')
   slicer.TkCall('pack %s -side top -fill x -padx 5 -pady 5' %
self.my_selector.GetWidgetName())

In the C++ version, .SetMRMLScene() was enough to establish a link between
the widget and the scene, however this is not the case in Python. Do I need
to handle an event, or update something periodically to ensure that my
selector widget displays the correct nodes in the current scene.

I also noticed there are multiple ways to obtain a scene, i.e.
slicer.MRMLScene, self.GetApplicationGUI().GetMRMLScene(),
self.GetLogic().GetMRMLScene(), what is the preferred way of getting the
current scene?

Thank you,
Ali
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://massmail.spl.harvard.edu/pipermail/slicer-users/attachments/20100319/cfb968ed/attachment.html>


More information about the slicer-users mailing list