How to use the slicer.util.mainWindow 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 SlicerRt / SlicerRT / Segmentations / EditorEffects / Python / SegmentEditorErodeEffect.py View on Github external
def createCursor(self, widget):
    # Turn off effect-specific cursor for this effect
    return slicer.util.mainWindow().cursor
github SlicerRt / SlicerRT / Segmentations / EditorEffects / Python / SegmentEditorSmoothingEffect.py View on Github external
def createCursor(self, widget):
    # Turn off effect-specific cursor for this effect
    return slicer.util.mainWindow().cursor
github SlicerDMRI / SlicerDMRI / Modules / Scripted / TractographyDownsample / TractographyDownsample.py View on Github external
widget = lm.viewport()
    elif type == slicer.qMRMLScreenShotDialog.ThreeD:
      # just the 3D window
      widget = lm.threeDWidget(0).threeDView()
    elif type == slicer.qMRMLScreenShotDialog.Red:
      # red slice window
      widget = lm.sliceWidget("Red")
    elif type == slicer.qMRMLScreenShotDialog.Yellow:
      # yellow slice window
      widget = lm.sliceWidget("Yellow")
    elif type == slicer.qMRMLScreenShotDialog.Green:
      # green slice window
      widget = lm.sliceWidget("Green")
    else:
      # default to using the full window
      widget = slicer.util.mainWindow()
      # reset the type so that the node is set correctly
      type = slicer.qMRMLScreenShotDialog.FullLayout

    # grab and convert to vtk image data
    qimage = ctk.ctkWidgetsUtils.grabWidget(widget)
    imageData = vtk.vtkImageData()
    slicer.qMRMLUtils().qImageToVtkImageData(qimage,imageData)

    annotationLogic = slicer.modules.annotations.logic()
    annotationLogic.CreateSnapShot(name, description, type, 1, imageData)
github SlicerRt / SlicerRT / SegmentEditor / SegmentEditor.py View on Github external
Key_Space = 0x20 # not in PythonQt
    self.shortcuts = []
    keysAndCallbacks = (
      # ('z', self.toolsBox.undoRedo.undo),
      # ('y', self.toolsBox.undoRedo.redo),
      ('h', self.toggleCrosshair),
      (Key_Escape, lambda : self.editor.setActiveEffect(None)),
      ('e', lambda : self.editor.setActiveEffect(self.editor.effectByName('Erase'))),
      ('p', lambda : self.editor.setActiveEffect(self.editor.effectByName('Paint'))),
      ('d', lambda : self.editor.setActiveEffect(self.editor.effectByName('Draw'))),
      ('w', lambda : self.editor.setActiveEffect(self.editor.effectByName('Wand'))),
      ('r', lambda : self.editor.setActiveEffect(self.editor.effectByName('Rectangle'))),
      # (Key_Space, self.toolsBox.toggleFloatingMode),
      )
    for key,callback in keysAndCallbacks:
      shortcut = qt.QShortcut(slicer.util.mainWindow())
      shortcut.setKey( qt.QKeySequence(key) )
      shortcut.connect( 'activated()', callback )
      self.shortcuts.append(shortcut)
github SlicerProstate / SliceTracker / SliceTracker / SliceTrackerUtils / steps / plugins / case.py View on Github external
def onCloseCaseButtonClicked(self):
    if not self.session.data.completed:
      dialog = qt.QMessageBox(qt.QMessageBox.Question, "SliceTracker", "Do you want to mark this case as completed?", qt.QMessageBox.Yes | qt.QMessageBox.No | qt.QMessageBox.Cancel, slicer.util.mainWindow(), qt.Qt.WindowStaysOnTopHint).exec_()
      if dialog == qt.QMessageBox.Yes:
        self.session.complete()
      elif dialog == qt.QMessageBox.Cancel:
        return
    if self.session.isRunning():
      self.session.close(save=False)