Debian Codegraph @

plugins/examples/datalab_example_empty.py

raw
1 # -*- coding: utf-8 -*-
2
3 """
4 Empty plugin example
5 ====================
6
7 This is an empty example of a DataLab plugin.
8
9 It adds a new menu entry in "Plugins" menu, with a sub-menu "Empty plugin (example)".
10 This sub-menu contains one action, "Do nothing".
11 """
12
13 import datalab.plugins
14
15
16 class EmptyPlugin(datalab.plugins.PluginBase):
17 """DataLab Example Plugin"""
18
19 PLUGIN_INFO = datalab.plugins.PluginInfo(
20 name="Empty plugin (example)",
21 version="1.0.0",
22 description="This is an empty example plugin",
23 )
24
25 def do_nothing(self) -> None:
26 """Do nothing"""
27 self.show_info("Do nothing")
28
29 def create_actions(self) -> None:
30 """Create actions"""
31 acth = self.imagepanel.acthandler
32 with acth.new_menu(self.PLUGIN_INFO.name):
33 # Note: in the following call, `select_condition` is by default `None`,
34 # so the action is enabled only if at least one image is selected.
35 acth.new_action("Do nothing", triggered=self.do_nothing)