Hello, I would like to learn in a scripted module, how to update the model color display once the model is selected in the slicer.qMRMLNodeComboBox() type of drop-down menu.
For example, is it about to update this line? or something else?
Setting MRML scene in the node combobox is necessary, so leave this line as is. Instead connect a method to the currentNodeChanged signal and in that method change the model’s color using modelNode.GetDisplayNode().SetColor(r,g,b).
Thanks, @lassoan
A follow-up question, to avoid all nodes turned to same highlight color, how should I return the previous selection to its original color upon every new selection in qMRMLNodeComboBox?
You store the node that you have just changed and its original color in member variables. Next time you change a new node, these member variables contain the previously selected node and its color.
Hi @lassoan, I suppose it is related to some syntax in Qt Signals and Slots which I am trying to read upon, but I am not sure why self.changedNode will become empty once “currentNodechanged” happens, could you please help a bit further? Thank you!
In Python, the callback funcrion is specified by only its name (no argument list). Look at examples in the programming tutorials to see the correct syntax of connect.
Oh right, there is no need to put member variables as arguments, thank you very much @lassoan , it worked!
Here’s how the definition looks like for restoring the previous node, to wrap up this thread of discussion.