-
Notifications
You must be signed in to change notification settings - Fork 7
Writing Plugins
New plugins are easy to create as they are written completely in Python. A number of tutorial plugins are included to show how a plugin can modify the behavior of Lasagna or stream data from the main application it to a plugin window. Note also that other than the methods to load a new base stack, all other file loading methods (such the plot overlay loader) are plugins too. This makes it easy to load data in new ways without needing to modify the core code. Similarly, see the IO modules where data classes such as imagestack
are defined.
When Lasagna starts the Lasagna class handles integration of plugins into the main program.
It does this by searching in user-defined directories for Python files that look like they may be plugins.
These are added as menu items.
In addition, plugins contain certain "hook" methods which are run at particular times by the Lasagna
class itself.
The Lasagna
class contains a hooks
property to which is assigned a dictionary.
This dictionary tell Lasagna
which plugin methods should be run at what times.
For example, Lasagna.updateMainWindowOnMouseMove
is a method runs continuously as the mouse moves over a figure axis.
The job of this method is to updates the cross-hairs and the status bar.
The dictionary key Lasagna.hooks.updateMainWindowOnMouseMove_End
contains a value which is a list of methods to be run once the cross hairs and status bar have finished being updated.
The tutorial plugin cross_section_plugin
has a method called hook_updateMainWindowOnMouseMove_End
.
meaning that this this method will run at this point.
This happens because cross_section_plugin
inherits LasagnaPlugin
which contains methods attachHooks
and detachHooks
, which find hook methods in a plugin and insert into or remove them from Lasagna.hooks
.