Slicer 5.6
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
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: https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#subject-hierarchy-plugin-offering-view-context-menu-action
28 """
29
30 def __init__(self, scriptedPlugin):
31 self.scriptedPlugin = scriptedPlugin
32
33 # Register plugin on initialization
34 self.register()
35
36 def register(self):
37 pluginHandlerSingleton = slicer.qSlicerSubjectHierarchyPluginHandler.instance()
38 pluginHandlerSingleton.registerPlugin(self.scriptedPlugin)
39 logging.debug("Scripted subject hierarchy plugin registered: " + self.scriptedPlugin.name)