Update Values at Widget

Hello,

I want to clarify and underand how to set values from Logic to the GUI.
So, I have a python module and I have Widget class where I define all my controls, for example:

class Widget(ScriptedLoadableModuleWidget):

self.textBox = qt.QLineEdit()

But I want from the Logic class to update the self.textBox text with the value.

class Logic(ScriptedLoadableModuleLogic):
value = 8

What is the right way to do that?

You should never update the GUI from the logic. The logic should not require, should not even know about that there is a GUI or not. Instead, the logic can update MRML nodes and since the GUI shows the current state of the MRML nodes, changes will automatically appear on the GUI. See these tutorials for details.

1 Like