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'
    label = 'Xyz'
    modulename = 'mypackage.myapplet'
    objectname = 'MyApplet'

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

entry_points={
    'oalab.applet': [
        'oalab.applet/mypackage = mypackage.plugin.builtin.applet',
    ],
    }

With mypackage.plugin.builtin.applet python module path (equivalent to 'mypackage/plugin/builtin/applet.py').

Details

class openalea.oalab.plugin.applet.IApplet(**kargs)[source]

Bases: openalea.core.interface.IInterface

Autonomous Graphical component

actions()[source]

Optional: list of all actions available for this applet See original QtGui.QWidget.actions method.

Example:

# instructions written in constructor
action_new = QtGui.QAction('New', self)
self.addAction(action_new)
global_toolbar_actions()[source]

Optional: list of actions to use in main toolbar. See toolbar

..warning:

these actions must have a global effect as they are added only one time in application.
For example, if you add two time applet "Viewer3D", menu_actions are added only one time.

To get global effects, action cat ...
    - manipulate core managers directly
    - manipulate singleton
    - iter on all applets of same type and apply effect on each

A contextual menu is also generated dynamically for current applet, see toolbar_actions, menu_actions
initialize()[source]

Optional method, called after instantiation

menu_actions()[source]

Optional: list of QAction/QMenu to use in contextual menu

menus()[source]

Optional: list of QMenu to use in main menu

toolbar_actions()[source]

Optional: list of actions to use in contextual toolbar

Example:

def toolbar_actions(self):
    action_new = QtGui.QAction("New")
    action_open = QtGui.QAction("Open")
    action_save = QtGui.QAction("Save")

    action_run = QtGui.QAction("Run")
    action_debug = QtGui.QAction("Debug")
    menu_run = QtGui.QMenu("Run")
    menu_run.addActions([action_run, action_debug])

    actions = [
        menu_run, # Menu syntax (generally transformed as toolbutton)
        action_new, # Default syntax
        {'action': action_open, 'style':0} # Dict syntax
    ]

Warning

List syntax ["Panel", "Group", action, style] is now deprecated. Use dict syntax instead

toolbars()[source]

Optional: return a list of QToolBar

class openalea.oalab.plugin.applet.IPluginApplet[source]

Bases: object

Graphical component displayed in main window. Component must respect IApplet interface.

Table Of Contents

Previous topic

<no title>

Next topic

OpenAleaLab's extensions

This Page