Creating a model combo box

Hey all,
I tried to create a combo box that will list mesh models, which i know fall under the general classification of ModelNode class, like this

modelNodeSelector = slicer.qMRMLNodeComboBox()
modelNodeSelector.objectName = ‘modelNodeSelector’
modelNodeSelector.toolTip = “Select a model.”
modelNodeSelector.nodeTypes = [‘vtkMRMLModelNode’]
modelNodeSelector.noneEnabled = True
modelNodeSelector.addEnabled = True
modelNodeSelector.removeEnabled = True
self.pathFormLayout.addRow(“Input Model:”, modelNodeSelector)
self.parent.connect(‘mrmlSceneChanged(vtkMRMLScene*)’, modelNodeSelector, ‘setMRMLScene(vtkMRMLScene*)’)

however the UI is grayed out and i cannot select anything. i suspect it has something to do with specifying the nodeTypes but im not sure. I have imported an STL model into the scene and it is visible in the Models viewer.

You need to set the MRML scene. I’m not sure that the parent connection that you are trying to use to set the scene is working. In scripted modules we usually set the scene using set method instead.

Note that manual widget creation is not recommended since you can now use a visual editor (Qt Designer) that is bundled with Slicer. It results in much less code, nicer look, with less development effort. See detailed tutorial here: https://www.slicer.org/wiki/Documentation/Nightly/Training#PerkLab.27s_Slicer_bootcamp_training_materials