def createUserInterface( self ): ''' ''' self.__layout = self.__parent.createUserInterface() # the colorpicker combobox self.__colorTableComboBox = slicer.qMRMLColorTableComboBox() self.__colorTableComboBox.setMRMLScene( slicer.mrmlScene ) # get current color node from the mrmlManager currentColorNodeID = self.mrmlManager().GetColorNodeID() currentColorNode = slicer.mrmlScene.GetNodeByID( currentColorNodeID ) if currentColorNode: self.__colorTableComboBox.setCurrentNode( currentColorNode ) self.__colorTableComboBox.connect( 'currentNodeChanged(vtkMRMLNode*)', self.onColorNodeChanged ) self.__layout.addWidget( self.__colorTableComboBox ) # the anatomical tree anatomicalTreeGroupBox = qt.QGroupBox() anatomicalTreeGroupBox.setTitle( 'Anatomical Tree' ) self.__layout.addWidget( anatomicalTreeGroupBox ) anatomicalTreeGroupBoxLayout = qt.QFormLayout( anatomicalTreeGroupBox ) self.__anatomicalTree = PythonQt.qSlicerEMSegmentModuleWidgets.qSlicerEMSegmentAnatomicalTreeWidget() self.__anatomicalTree.structureNameEditable = True self.__anatomicalTree.labelColumnVisible = True self.__anatomicalTree.addDeleteSubclassesEnabled = True self.__anatomicalTree.setSizePolicy( qt.QSizePolicy.MinimumExpanding, qt.QSizePolicy.MinimumExpanding ) anatomicalTreeGroupBoxLayout.addWidget( self.__anatomicalTree )
def colorSelectDialog(self): """color table dialog""" if not self.colorSelect: self.colorSelect = qt.QDialog(slicer.util.mainWindow()) self.colorSelect.objectName = 'EditorColorSelectDialog' self.colorSelect.setLayout( qt.QVBoxLayout() ) self.colorPromptLabel = qt.QLabel() self.colorSelect.layout().addWidget( self.colorPromptLabel ) self.colorSelectorFrame = qt.QFrame() self.colorSelectorFrame.objectName = 'ColorSelectorFrame' self.colorSelectorFrame.setLayout( qt.QHBoxLayout() ) self.colorSelect.layout().addWidget( self.colorSelectorFrame ) self.colorSelectorLabel = qt.QLabel() self.colorPromptLabel.setText( "Color Table: " ) self.colorSelectorFrame.layout().addWidget( self.colorSelectorLabel ) self.colorSelector = slicer.qMRMLColorTableComboBox() # TODO self.colorSelector.nodeTypes = ("vtkMRMLColorNode", "") self.colorSelector.hideChildNodeTypes = ("vtkMRMLDiffusionTensorDisplayPropertiesNode", "") self.colorSelector.addEnabled = False self.colorSelector.removeEnabled = False self.colorSelector.noneEnabled = False self.colorSelector.selectNodeUponCreation = True self.colorSelector.showHidden = True self.colorSelector.showChildNodeTypes = True self.colorSelector.setMRMLScene( slicer.mrmlScene ) self.colorSelector.setToolTip( "Pick the table of structures you wish to edit" ) self.colorSelect.layout().addWidget( self.colorSelector ) # pick the default editor LUT for the user defaultID = self.colorLogic.GetDefaultEditorColorNodeID() defaultNode = slicer.mrmlScene.GetNodeByID(defaultID) if defaultNode: self.colorSelector.setCurrentNode( defaultNode ) self.colorButtonFrame = qt.QFrame() self.colorButtonFrame.objectName = 'ColorButtonFrame' self.colorButtonFrame.setLayout( qt.QHBoxLayout() ) self.colorSelect.layout().addWidget( self.colorButtonFrame ) self.colorDialogApply = qt.QPushButton("Apply", self.colorButtonFrame) self.colorDialogApply.objectName = 'ColorDialogApply' self.colorDialogApply.setToolTip( "Use currently selected color node." ) self.colorButtonFrame.layout().addWidget(self.colorDialogApply) self.colorDialogCancel = qt.QPushButton("Cancel", self.colorButtonFrame) self.colorDialogCancel.objectName = 'ColorDialogCancel' self.colorDialogCancel.setToolTip( "Cancel current operation." ) self.colorButtonFrame.layout().addWidget(self.colorDialogCancel) self.colorDialogApply.connect("clicked()", self.onColorDialogApply) self.colorDialogCancel.connect("clicked()", self.colorSelect.hide) self.colorPromptLabel.setText( "Create a merge label map for selected master volume %s.\nNew volume will be %s.\nSelect the color table node will be used for segmentation labels." %(self.master.GetName(), self.master.GetName()+"-label")) self.colorSelect.show()
def colorSelectDialog(self): """color table dialog""" if not self.colorSelect: self.colorSelect = qt.QDialog(slicer.util.mainWindow()) self.colorSelect.objectName = 'EditorColorSelectDialog' self.colorSelect.setLayout( qt.QVBoxLayout() ) self.colorPromptLabel = qt.QLabel() self.colorSelect.layout().addWidget( self.colorPromptLabel ) self.colorSelectorFrame = qt.QFrame() self.colorSelectorFrame.objectName = 'ColorSelectorFrame' self.colorSelectorFrame.setLayout( qt.QHBoxLayout() ) self.colorSelect.layout().addWidget( self.colorSelectorFrame ) self.colorSelectorLabel = qt.QLabel() self.colorPromptLabel.setText( "Color Table: " ) self.colorSelectorFrame.layout().addWidget( self.colorSelectorLabel ) self.colorSelector = slicer.qMRMLColorTableComboBox() # TODO self.colorSelector.nodeTypes = ("vtkMRMLColorNode", "") self.colorSelector.hideChildNodeTypes = ("vtkMRMLDiffusionTensorDisplayPropertiesNode", "vtkMRMLProceduralColorNode", "") self.colorSelector.addEnabled = False self.colorSelector.removeEnabled = False self.colorSelector.noneEnabled = False self.colorSelector.selectNodeUponCreation = True self.colorSelector.showHidden = True self.colorSelector.showChildNodeTypes = True self.colorSelector.setMRMLScene( slicer.mrmlScene ) self.colorSelector.setToolTip( "Pick the table of structures you wish to edit" ) self.colorSelect.layout().addWidget( self.colorSelector ) # pick the default editor LUT for the user defaultID = self.colorLogic.GetDefaultEditorColorNodeID() defaultNode = slicer.mrmlScene.GetNodeByID(defaultID) if defaultNode: self.colorSelector.setCurrentNode( defaultNode ) self.colorButtonFrame = qt.QFrame() self.colorButtonFrame.objectName = 'ColorButtonFrame' self.colorButtonFrame.setLayout( qt.QHBoxLayout() ) self.colorSelect.layout().addWidget( self.colorButtonFrame ) self.colorDialogApply = qt.QPushButton("Apply", self.colorButtonFrame) self.colorDialogApply.objectName = 'ColorDialogApply' self.colorDialogApply.setToolTip( "Use currently selected color node." ) self.colorButtonFrame.layout().addWidget(self.colorDialogApply) self.colorDialogCancel = qt.QPushButton("Cancel", self.colorButtonFrame) self.colorDialogCancel.objectName = 'ColorDialogCancel' self.colorDialogCancel.setToolTip( "Cancel current operation." ) self.colorButtonFrame.layout().addWidget(self.colorDialogCancel) self.colorDialogApply.connect("clicked()", self.onColorDialogApply) self.colorDialogCancel.connect("clicked()", self.colorSelect.hide) self.colorPromptLabel.setText( "Create a merge label map for selected master volume %s.\nNew volume will be %s.\nSelect the color table node that will be used for segmentation labels." %(self.master.GetName(), self.master.GetName()+"-label")) self.colorSelect.show()
def createUserInterface(self): ''' ''' self.__layout = super(EMSegmentQuickStep2, self).createUserInterface() # the colorpicker combobox self.__colorTableComboBox = slicer.qMRMLColorTableComboBox() self.__colorTableComboBox.setMRMLScene(slicer.mrmlScene) self.__colorTableComboBox.toolTip = 'The label colors are defined using this look-up table.' infoLabel = qt.QLabel( "Choose the look-up table for label colorization:") self.__layout.addWidget(infoLabel) # get current color node from the mrmlManager currentColorNodeID = self.mrmlManager().GetColorNodeID() currentColorNode = slicer.mrmlScene.GetNodeByID(currentColorNodeID) if currentColorNode: self.__colorTableComboBox.setCurrentNode(currentColorNode) self.__colorTableComboBox.connect('currentNodeChanged(vtkMRMLNode*)', self.onColorNodeChanged) self.__layout.addWidget(self.__colorTableComboBox) # add empty row self.__layout.addRow("", qt.QWidget()) # add empty row self.__layout.addRow("", qt.QWidget()) # add empty row self.__layout.addRow("", qt.QWidget()) # the anatomical tree anatomicalTreeGroupBox = qt.QGroupBox() anatomicalTreeGroupBox.setTitle('Anatomical Tree') self.__layout.addWidget(anatomicalTreeGroupBox) anatomicalTreeGroupBoxLayout = qt.QFormLayout(anatomicalTreeGroupBox) self.__anatomicalTree = slicer.modulewidget.qSlicerEMSegmentAnatomicalTreeWidget( ) self.__anatomicalTree.structureNameVisible = False self.__anatomicalTree.structureNameEditable = False self.__anatomicalTree.labelColumnVisible = True self.__anatomicalTree.addDeleteSubclassesEnabled = True self.__anatomicalTree.toolTip = 'Please configure a hierarchy of structures for the input datasets.' self.__anatomicalTree.setSizePolicy(qt.QSizePolicy.MinimumExpanding, qt.QSizePolicy.MinimumExpanding) anatomicalTreeGroupBoxLayout.addWidget(self.__anatomicalTree) self.__anatomicalTree.disableUpdateValueFlag = False
def createUserInterface( self ): ''' ''' self.__layout = super( EMSegmentQuickStep2, self ).createUserInterface() # the colorpicker combobox self.__colorTableComboBox = slicer.qMRMLColorTableComboBox() self.__colorTableComboBox.setMRMLScene( slicer.mrmlScene ) self.__colorTableComboBox.toolTip = 'The label colors are defined using this look-up table.' infoLabel = qt.QLabel( "Choose the look-up table for label colorization:" ) self.__layout.addWidget( infoLabel ) # get current color node from the mrmlManager currentColorNodeID = self.mrmlManager().GetColorNodeID() currentColorNode = slicer.mrmlScene.GetNodeByID( currentColorNodeID ) if currentColorNode: self.__colorTableComboBox.setCurrentNode( currentColorNode ) self.__colorTableComboBox.connect( 'currentNodeChanged(vtkMRMLNode*)', self.onColorNodeChanged ) self.__layout.addWidget( self.__colorTableComboBox ) # add empty row self.__layout.addRow( "", qt.QWidget() ) # add empty row self.__layout.addRow( "", qt.QWidget() ) # add empty row self.__layout.addRow( "", qt.QWidget() ) # the anatomical tree anatomicalTreeGroupBox = qt.QGroupBox() anatomicalTreeGroupBox.setTitle( 'Anatomical Tree' ) self.__layout.addWidget( anatomicalTreeGroupBox ) anatomicalTreeGroupBoxLayout = qt.QFormLayout( anatomicalTreeGroupBox ) self.__anatomicalTree = slicer.modulewidget.qSlicerEMSegmentAnatomicalTreeWidget() self.__anatomicalTree.structureNameVisible = False self.__anatomicalTree.structureNameEditable = False self.__anatomicalTree.labelColumnVisible = True self.__anatomicalTree.addDeleteSubclassesEnabled = True self.__anatomicalTree.toolTip = 'Please configure a hierarchy of structures for the input datasets.' self.__anatomicalTree.setSizePolicy( qt.QSizePolicy.MinimumExpanding, qt.QSizePolicy.MinimumExpanding ) anatomicalTreeGroupBoxLayout.addWidget( self.__anatomicalTree ) self.__anatomicalTree.disableUpdateValueFlag = False
def setup(self): # Instantiate and connect widgets ... # # Reload and Test area # reloadCollapsibleButton = ctk.ctkCollapsibleButton() reloadCollapsibleButton.text = "Reload && Test" self.layout.addWidget(reloadCollapsibleButton) reloadFormLayout = qt.QFormLayout(reloadCollapsibleButton) # reload button # (use this during development, but remove it when delivering # your module to users) self.reloadButton = qt.QPushButton("Reload") self.reloadButton.toolTip = "Reload this module." self.reloadButton.name = "AblationMarginVisualizer Reload" reloadFormLayout.addWidget(self.reloadButton) self.reloadButton.connect('clicked()', self.onReload) # # Basic Area # basicCollapsibleButton = ctk.ctkCollapsibleButton() basicCollapsibleButton.text = "Basic" self.layout.addWidget(basicCollapsibleButton) # Layout within the dummy collapsible button basicFormLayout = qt.QFormLayout(basicCollapsibleButton) # # Tumor label selector # self.tumorLabelSelector = slicer.qMRMLNodeComboBox() self.tumorLabelSelector.nodeTypes = (("vtkMRMLScalarVolumeNode"), "") self.tumorLabelSelector.addAttribute("vtkMRMLScalarVolumeNode", "LabelMap", 1) self.tumorLabelSelector.selectNodeUponCreation = True self.tumorLabelSelector.addEnabled = False self.tumorLabelSelector.removeEnabled = False self.tumorLabelSelector.noneEnabled = False self.tumorLabelSelector.showHidden = False self.tumorLabelSelector.showChildNodeTypes = False self.tumorLabelSelector.setMRMLScene(slicer.mrmlScene) self.tumorLabelSelector.setToolTip( "Select label image of the tumor volume") basicFormLayout.addRow("Tumor Volume: ", self.tumorLabelSelector) self.outputModelSelector = slicer.qMRMLNodeComboBox() self.outputModelSelector.nodeTypes = (("vtkMRMLModelNode"), "") self.outputModelSelector.selectNodeUponCreation = False self.outputModelSelector.addEnabled = False self.outputModelSelector.renameEnabled = False self.outputModelSelector.removeEnabled = False self.outputModelSelector.noneEnabled = False self.outputModelSelector.showHidden = False self.outputModelSelector.showChildNodeTypes = False self.outputModelSelector.setMRMLScene(slicer.mrmlScene) self.outputModelSelector.setToolTip( "Select a surface model of the ablation volume") basicFormLayout.addRow("Ablation Volume Model: ", self.outputModelSelector) # # Apply Button # self.applyButton = qt.QPushButton("Apply") self.applyButton.toolTip = "Run the algorithm." self.applyButton.enabled = True basicFormLayout.addRow(self.applyButton) self.applyButton.connect('clicked(bool)', self.onApplyButton) # # Visualization Area # visualizationCollapsibleButton = ctk.ctkCollapsibleButton() visualizationCollapsibleButton.text = "Visualization" self.layout.addWidget(visualizationCollapsibleButton) # Layout within the dummy collapsible button visualizationFormLayout = qt.QFormLayout( visualizationCollapsibleButton) self.colorMapSelector = slicer.qMRMLColorTableComboBox() self.colorMapSelector.setMRMLScene(slicer.mrmlScene) visualizationFormLayout.addRow("Color Table: ", self.colorMapSelector) self.colorMapSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onColorTableSelect) #self.colorRangeWidget = slicer.qMRMLRangeWidget() self.colorRangeWidget = ctk.ctkRangeWidget() self.colorRangeWidget.setToolTip("Set color range") visualizationFormLayout.addRow("Color Range: ", self.colorRangeWidget) self.colorRangeWidget.connect('valuesChanged(double, double)', self.updateColorRange) self.showScaleButton = qt.QCheckBox() self.showScaleButton.setText('Show Scale') self.showScaleButton.checked = False self.showScaleButton.setToolTip( 'Check to show the scale bar in the 3D viewer') visualizationFormLayout.addRow("Ablation Volume Model: ", self.showScaleButton) self.showScaleButton.connect('clicked(bool)', self.onShowScaleButton) # connections #self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) #self.outputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) # Add vertical spacer self.layout.addStretch(1) ## Create a scale self.scalarBarWidget = vtk.vtkScalarBarWidget() actor = self.scalarBarWidget.GetScalarBarActor() actor.SetOrientationToVertical() actor.SetNumberOfLabels(11) actor.SetTitle("") actor.SetLabelFormat(" %#8.3f") actor.SetPosition(0.1, 0.1) actor.SetWidth(0.1) actor.SetHeight(0.8) self.scalarBarWidget.SetEnabled(0) layout = slicer.app.layoutManager() view = layout.threeDWidget(0).threeDView() renderer = layout.activeThreeDRenderer() self.scalarBarWidget.SetInteractor( renderer.GetRenderWindow().GetInteractor())
def setup(self): # Instantiate and connect widgets ... # reload button # (use this during development, but remove it when delivering # your module to users) self.reloadButton = qt.QPushButton("Reload") self.reloadButton.toolTip = "Reload this module." self.reloadButton.name = "PointColorMap Reload" self.layout.addWidget(self.reloadButton) self.reloadButton.connect('clicked()', self.onReload) # MarkupsFiducial Node Selector self.aLS = slicer.qMRMLNodeComboBox() self.aLS.setMRMLScene(slicer.mrmlScene) self.aLS.nodeTypes = (["vtkMRMLMarkupsFiducialNode"]) self.aLS.connect('currentNodeChanged(vtkMRMLNode*)', self.setMarkupListNode) self.layout.addWidget(self.aLS) # ColorMap selector self.cmS = slicer.qMRMLColorTableComboBox() self.cmS.setMRMLScene(slicer.mrmlScene) self.layout.addWidget(self.cmS) # Discrete Checkbox self.dsctCB = qt.QCheckBox() self.dsctCB.setText("Discrete Colors") self.layout.addWidget(self.dsctCB) # Discrete Checkbox self.scale1CB = qt.QCheckBox() self.scale1CB.setText("Concentration colors") self.layout.addWidget(self.scale1CB) # Manual color scale self.manualCmapCB = qt.QCheckBox() self.manualCmapCB.setText("Fixed range") self.layout.addWidget(self.manualCmapCB) self.manualCmapRange1 = qt.QLineEdit() self.manualCmapRange1L = qt.QLabel() self.manualCmapRange1L.setText("Low:") self.manualCmapRange2 = qt.QLineEdit() self.manualCmapRange2L = qt.QLabel() self.manualCmapRange2L.setText("High:") self.manualCmapRangeLayout = qt.QHBoxLayout() self.manualCmapRangeLayout.addWidget(self.manualCmapRange1L) self.manualCmapRangeLayout.addWidget(self.manualCmapRange1) self.manualCmapRangeLayout.addWidget(self.manualCmapRange2L) self.manualCmapRangeLayout.addWidget(self.manualCmapRange2) self.manualCmapRangeFrame = qt.QFrame() self.manualCmapRangeFrame.setLayout(self.manualCmapRangeLayout) self.layout.addWidget(self.manualCmapRangeFrame) # Data Table View self.plView = qt.QTableView() self.plViewModel = qt.QStandardItemModel() self.plView.sortingEnabled = True vHeader = self.plView.verticalHeader() vHeader.hide() hHeader = self.plView.horizontalHeader() self.layout.addWidget(self.plView) # Paste action for data table paste = qt.QAction(self.plView) paste.setText("") paste.setShortcut( qt.QKeySequence('Ctrl+V') ) paste.connect('triggered()', self.pasteData) self.plView.addAction(paste) # Update Button self.updateButton = qt.QPushButton("Apply ColorMap") self.updateButton.connect('clicked()', self.updateColorMap) self.layout.addWidget(self.updateButton) # Toggle text display checkbox self.tdCB = qt.QCheckBox() self.tdCB.setText("Toggle Label Display") self.tdCB.connect('stateChanged(int)', self.toggleTextDisplay) self.layout.addWidget(self.tdCB)
def setup(self): # Instantiate and connect widgets ... # # Reload and Test area # reloadCollapsibleButton = ctk.ctkCollapsibleButton() reloadCollapsibleButton.text = "Reload && Test" self.layout.addWidget(reloadCollapsibleButton) reloadFormLayout = qt.QFormLayout(reloadCollapsibleButton) # reload button # (use this during development, but remove it when delivering # your module to users) self.reloadButton = qt.QPushButton("Reload") self.reloadButton.toolTip = "Reload this module." self.reloadButton.name = "AblationMarginVisualizer Reload" reloadFormLayout.addWidget(self.reloadButton) self.reloadButton.connect('clicked()', self.onReload) # # Basic Area # basicCollapsibleButton = ctk.ctkCollapsibleButton() basicCollapsibleButton.text = "Basic" self.layout.addWidget(basicCollapsibleButton) # Layout within the dummy collapsible button basicFormLayout = qt.QFormLayout(basicCollapsibleButton) # # Tumor label selector # self.tumorLabelSelector = slicer.qMRMLNodeComboBox() self.tumorLabelSelector.nodeTypes = ( ("vtkMRMLScalarVolumeNode"), "" ) self.tumorLabelSelector.addAttribute( "vtkMRMLScalarVolumeNode", "LabelMap", 1 ) self.tumorLabelSelector.selectNodeUponCreation = True self.tumorLabelSelector.addEnabled = False self.tumorLabelSelector.removeEnabled = False self.tumorLabelSelector.noneEnabled = False self.tumorLabelSelector.showHidden = False self.tumorLabelSelector.showChildNodeTypes = False self.tumorLabelSelector.setMRMLScene( slicer.mrmlScene ) self.tumorLabelSelector.setToolTip( "Select label image of the tumor volume" ) basicFormLayout.addRow("Tumor Volume: ", self.tumorLabelSelector) self.outputModelSelector = slicer.qMRMLNodeComboBox() self.outputModelSelector.nodeTypes = ( ("vtkMRMLModelNode"), "" ) self.outputModelSelector.selectNodeUponCreation = False self.outputModelSelector.addEnabled = False self.outputModelSelector.renameEnabled = False self.outputModelSelector.removeEnabled = False self.outputModelSelector.noneEnabled = False self.outputModelSelector.showHidden = False self.outputModelSelector.showChildNodeTypes = False self.outputModelSelector.setMRMLScene( slicer.mrmlScene ) self.outputModelSelector.setToolTip( "Select a surface model of the ablation volume" ) basicFormLayout.addRow("Ablation Volume Model: ", self.outputModelSelector) # # Apply Button # self.applyButton = qt.QPushButton("Apply") self.applyButton.toolTip = "Run the algorithm." self.applyButton.enabled = True basicFormLayout.addRow(self.applyButton) self.applyButton.connect('clicked(bool)', self.onApplyButton) # # Visualization Area # visualizationCollapsibleButton = ctk.ctkCollapsibleButton() visualizationCollapsibleButton.text = "Visualization" self.layout.addWidget(visualizationCollapsibleButton) # Layout within the dummy collapsible button visualizationFormLayout = qt.QFormLayout(visualizationCollapsibleButton) self.colorMapSelector = slicer.qMRMLColorTableComboBox() self.colorMapSelector.setMRMLScene( slicer.mrmlScene ) visualizationFormLayout.addRow("Color Table: ", self.colorMapSelector) self.colorMapSelector.connect('currentNodeChanged(vtkMRMLNode*)', self.onColorTableSelect) #self.colorRangeWidget = slicer.qMRMLRangeWidget() self.colorRangeWidget = ctk.ctkRangeWidget() self.colorRangeWidget.setToolTip("Set color range") visualizationFormLayout.addRow("Color Range: ", self.colorRangeWidget) self.colorRangeWidget.connect('valuesChanged(double, double)', self.updateColorRange) self.showScaleButton = qt.QCheckBox() self.showScaleButton.setText('Show Scale') self.showScaleButton.checked = False self.showScaleButton.setToolTip('Check to show the scale bar in the 3D viewer') visualizationFormLayout.addRow("Ablation Volume Model: ", self.showScaleButton) self.showScaleButton.connect('clicked(bool)', self.onShowScaleButton) # connections #self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) #self.outputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect) # Add vertical spacer self.layout.addStretch(1) ## Create a scale self.scalarBarWidget = vtk.vtkScalarBarWidget() actor = self.scalarBarWidget.GetScalarBarActor() actor.SetOrientationToVertical() actor.SetNumberOfLabels(11) actor.SetTitle("") actor.SetLabelFormat(" %#8.3f") actor.SetPosition(0.1, 0.1) actor.SetWidth(0.1) actor.SetHeight(0.8) self.scalarBarWidget.SetEnabled(0) layout = slicer.app.layoutManager() view = layout.threeDWidget(0).threeDView() renderer = layout.activeThreeDRenderer() self.scalarBarWidget.SetInteractor(renderer.GetRenderWindow().GetInteractor())