How to use the slicer.util.findChildren function in slicer

To help you get started, we’ve selected a few slicer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SlicerDMRI / SlicerDMRI / Modules / Loadable / TractographyDisplay / Testing / Python / View on Github external
color_by_strategies = [
        ('Solid Color', displayNode.colorModeSolid),
        ('Of Tensor Property', displayNode.colorModeScalar),
#        (, displayNode.colorModeFunctionOfScalar),
#        ('Color Fibers By Mean Orientation', displayNode.colorModeUseCellScalars),
        ('Of Scalar Value', displayNode.colorModeScalarData),
        ('Color Fibers By Segment Orientation', displayNode.colorModePointFiberOrientation),
        ('Color Fibers By Mean Orientation', displayNode.colorModeMeanFiberOrientation),
    for widget_text, color_code in color_by_strategies:

        if not visibility.checked:

        solidColor = slicer.util.findChildren(tubeTab, text=widget_text)
        if len(solidColor) == 0:
            raise ValueError("Widget %s not found" % widget_text)
            solidColor = solidColor[0]

        if displayNode and displayNode.GetColorMode() != color_code:
            self.delayDisplay('Setting Color Mode To %s Did not Work' % widget_text)
            raise Exception()
            self.delayDisplay("Setting Color Mode To %s Worked" % widget_text)
github SlicerDMRI / SlicerDMRI / Modules / Loadable / TractographyDisplay / Testing / Python / View on Github external
def test_TestTractographyDisplayColorBy(self, display_node='Tube'):
    self.delayDisplay("Starting the test")

    self.delayDisplay('Showing Advanced Display\n')
    advancedDisplay = slicer.util.findChildren(text='Advanced Display')[0]
    advancedDisplay.collapsed = False

    self.delayDisplay('Selecting tract1\n')
    tractNode = slicer.util.getNode('tract1')
    displayNode = getattr(tractNode, 'Get%sDisplayNode' % display_node)()
    tree = slicer.util.findChildren(name='TractographyDisplayTreeView')[0]
    model = tree.model()
    modelIndex = model.indexFromMRMLNode(tractNode)

    tubeTab = slicer.util.findChildren(advancedDisplay, name='%sTab' % display_node)[0]

    visibility = slicer.util.findChildren(tubeTab, text='Visibility')[0]

    color_by_strategies = [
        ('Solid Color', displayNode.colorModeSolid),
github QIICR / QuantitativeReporting / Util / LabelToDICOMSEGConverter / View on Github external
# reload the source code
    # - set source file path
    # - load the module to the global space
    filePath = eval('slicer.modules.%s.path' % moduleName.lower())
    p = os.path.dirname(filePath)
    if not sys.path.__contains__(p):
    fp = open(filePath, "r")
    globals()[moduleName] = imp.load_module(
        moduleName, fp, filePath, ('.py', 'r', imp.PY_SOURCE))

    # rebuild the widget
    # - find and hide the existing widget
    # - create a new widget in the existing parent
    parent = slicer.util.findChildren(name='%s Reload' % moduleName)[0].parent()
    for child in parent.children():
      except AttributeError:
    # Remove spacer items
    item = parent.layout().itemAt(0)
    while item:
      item = parent.layout().itemAt(0)
    # create new widget inside existing parent
    globals()[widgetName.lower()] = eval(
        'globals()["%s"].%s(parent)' % (moduleName, widgetName))