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