File: datalab_example_empty.py

package info (click to toggle)
datalab 1.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 36,260 kB
  • sloc: python: 29,592; makefile: 3
file content (35 lines) | stat: -rw-r--r-- 1,026 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# -*- coding: utf-8 -*-

"""
Empty plugin example
====================

This is an empty example of a DataLab plugin.

It adds a new menu entry in "Plugins" menu, with a sub-menu "Empty plugin (example)".
This sub-menu contains one action, "Do nothing".
"""

import datalab.plugins


class EmptyPlugin(datalab.plugins.PluginBase):
    """DataLab Example Plugin"""

    PLUGIN_INFO = datalab.plugins.PluginInfo(
        name="Empty plugin (example)",
        version="1.0.0",
        description="This is an empty example plugin",
    )

    def do_nothing(self) -> None:
        """Do nothing"""
        self.show_info("Do nothing")

    def create_actions(self) -> None:
        """Create actions"""
        acth = self.imagepanel.acthandler
        with acth.new_menu(self.PLUGIN_INFO.name):
            # Note: in the following call, `select_condition` is by default `None`,
            # so the action is enabled only if at least one image is selected.
            acth.new_action("Do nothing", triggered=self.do_nothing)