Applets

Overview

Note

To define an applet plugin, you must
  1. write an AppletPlugin class that respects IPluginApplet interface (see below)
  2. add it to group oalab.applet

1. Copy paste this code and fill it with right names and instructions. (replace all xyz, respecting case, with your applet name). For example Xyz -> HelpApplet

class PluginXyz(object):

    name = 'Xyz'
    alias = 'Xyz'

    def __call__(self):
        # Write your code here
        pass

    def graft(self, **kwds):
        # Write your code here
        pass

To avoid to rewrite all plugins from scratch, you can derivate your plugin from PluginApplet :

from openalea.oalab.plugins.applets import PluginApplet
class PluginXyz(PluginApplet):
    pass

2. Once this class has been written, just register it in the setup.py file of your python package.

entry_points={
    'oalab.applet': [
        'Xyz = mypackage.plugins:PluginXyz',
        ]
    }

With mypackage.plugins python module path (equivalent to 'mypackage/plugins.py') and 'PluginXyz' the class name.

Example

The module called oalab.gui.help provides this help widget:

OpenAleaLab is the main application that gather all widgets. We want to add HelpWidget in the MainWindow and allow communication between both classes. For that purpose, we create a Plugin called HelpWidgetPlugin in helper package:

It is very important to notice that adding widget in the right area is done by the plugin, not the application. Application does almost nothing, it is just a container of widgets. Real application intelligence is delegated to Plugins (placing and linking components) and components (doing real treatments).

Finally, we register this plugin in setup.py of package helper.

Details

class openalea.oalab.plugins.applets.PluginApplet

Partial implementation of a plugin applet. You can use it by derivating your class from PluginApplet.

Table Of Contents

Previous topic

Plugins

Next topic

Controls

This Page