Slicer  5.3
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
AbstractScriptedSubjectHierarchyPlugin.py
Go to the documentation of this file.
1 import logging
2 
3 import slicer
4 
5 
6 #
7 # Abstract class of python scripted subject hierarchy plugins
8 #
9 
11  """ Abstract scripted subject hierarchy plugin for python scripted plugins
12 
13  USAGE: Instantiate scripted subject hierarchy plugin adaptor class from
14  module (e.g. from setup function), and set python source:
15 
16  from SubjectHierarchyPlugins import *
17  ...
18  class [Module]Widget(ScriptedLoadableModuleWidget):
19  ...
20  def setup(self):
21  ...
22  scriptedPlugin = slicer.qSlicerSubjectHierarchyScriptedPlugin(None)
23  scriptedPlugin.setPythonSource(VolumeClipSubjectHierarchyPlugin.filePath)
24  ...
25 
26  Example can be found here: https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#subject-hierarchy-plugin-offering-view-context-menu-action
27  """
28 
29  def __init__(self, scriptedPlugin):
30  self.scriptedPlugin = scriptedPlugin
31 
32  # Register plugin on initialization
33  self.register()
34 
35  def register(self):
36  pluginHandlerSingleton = slicer.qSlicerSubjectHierarchyPluginHandler.instance()
37  pluginHandlerSingleton.registerPlugin(self.scriptedPlugin)
38  logging.debug('Scripted subject hierarchy plugin registered: ' + self.scriptedPlugin.name)