AttributeError: qMRMLNodeComboBox has no attribute named 'setNoneEnabled'

Operating system: Ubuntu 20.04
Slicer version: 4.11.20210226
Expected behavior: setNoneEnabled() to disable qMRMLNodeComboBox “none” option
Actual behavior: reported error

My code:

self.ui.fid1MRMLNodeComboBox.nodeTypes = [‘vtkMRMLMarkupsFiducialNode’]
self.ui.fid1MRMLNodeComboBox.setNoneEnabled(False)

Bug:
Traceback (most recent call last):
File “/home/yl/se/TMSKuka/TMSKukaGUI/TMSKukaGUI.py”, line 92, in setup
self.ui.fid1MRMLNodeComboBox.setNoneEnabled(False)
AttributeError: qMRMLNodeComboBox has no attribute named ‘setNoneEnabled’
Slicer Docs:
https://apidocs.slicer.org/master/qMRMLNodeComboBox_8h_source.html
https://apidocs.slicer.org/master/classqMRMLNodeComboBox.html#a60aadef87aa219043a0177780f22d855

From Python this property “noneEnabled” is set directly. You can find examples of its usage in python by searching the Slicer GitHub repo.

self.ui.fid1MRMLNodeComboBox.noneEnabled = False
2 Likes

You may find useful this documentation page, which describes how to read doxygen-generated documentation in Python.

1 Like

Thank you for your reply. Yes I tried it and it worked.

Thank you very much! This is very helpful. I should have seen this earlier.

1 Like