qRadioButtons and parameter nodes

Hi all,

I am having a lot of trouble trying to save and recall the state of a pair of radio buttons (which I have put in a scripted module GUI) from a parameter node.

I have got all my qMRMLNodeComboBox and qSpinBoxes all saving and updating fine but I am having terrible trouble with the qRadioButtons.

Can anyone think of any scripted modules which save and recall the state of radio buttons from a parameter node which I can look at for ideas? I have sifted through quite a few on github but cant find any which use both a parameter node for saving the GUI state and have radio buttons.


See how radio buttons are managed in this Mask Volume effect: https://github.com/lassoan/SlicerSegmentEditorExtraEffects/blob/master/SegmentEditorMaskVolume/SegmentEditorMaskVolumeLib/SegmentEditorEffect.py

1 Like

Hi Andras,
I am not understanding this error.

File “/home/saima/Slicer-4.11.0-2020-02-25-linux-amd64/ElectricaConductivity/FuzzyClassification/FuzzyClassification.py”, line 136, in updateGUIFromParameterNode
self.ui.nClass.value = int(self._parameterNode.GetParameter(“nnClass”))
AttributeError: ‘setvalue’ does not exist on QSpinBox and creating new attributes on C++ objects is not allowed

I am trying to create a qspinbox and enabling pathlineedits depending on the qspin value

Siama Safdar

The code that is in the .py file is not the same that is being executed: the referenced line contains self.ui.nClass.value, while you are executing self.ui.nClass.setvalue. Restart Slicer to ensure that all previous versions of the module are unloaded.

setvalue is indeed incorrect, there is no such method of QSpinBox. You need to fix spelling and write self.ui.nClass.setValue(...) or use the value property (self.ui.nClass.value = ...).