Graphical Components

Build new graphical application

OpenAleaLab proposes classes to create generic "labs". A lab is a graphical interfaces providing several features :

  • python shell: runs scripts
  • editors : view and edit scripts, workflow, ...
  • managers: manage packages, plugins and projects
  • viewer: displays a scene in 2d or 3d
  • scene: a generic representation of all data used in simulation
  • reporting: show logs, history, ...

Library also provides generic object to ease GUI creation like ribbon bars, mainwindow classes, but OpenAleaLab is not a generic application framework like Qt.

Builtin widget to ease Graphical Application development

Group node widgets

from openalea.core import Node, Factory, IBool, IInt, IStr
from openalea.core.node import FuncNode
from openalea.core.traitsui import View, Group, Item
from openalea.visualea.node_widget import DefaultNodeWidget

view = View(
    Group('Custom Control',
        Group('AB Group', Item('a'), Item('b'), layout="-"),
        Group('C Group', Item('c')),
        layout='|'),
    )

inputs = [
    {'interface': IBool, 'name': 'a', 'value': False, 'desc': ''},
    {'interface': IInt, 'name': 'b', 'value': 0, 'desc': ''},
    {'interface': IStr, 'name': 'c', 'value': '', 'desc': ''}
    ]

node_factory = Factory(name='myfunc',
                authors=' (wralea authors)',
                description='',
                category='Unclassified',
                nodemodule='lib',
                nodeclass='myfunc',
                inputs=inputs,
                view=view,
                )

if __name__ == '__main__':
    from openalea.vpltk.qt import QtGui
    app = QtGui.QApplication([])
    node = node_factory.instantiate()
    w = DefaultNodeWidget(node, parent=None)
    w.show()
    app.exec_()

Create Paned menus (Ribbon bars)

Paned menus, also called "ribbon bars" are alternatives to classical Tool bars. It allows to emphasize some action with larger buttons. To create a Paned menu, you just need to create a PanedMenu and add QAction with addBtnByAction() method.

PanedMenu components :

../../../_images/api_ribbon_bar.png

Main classes and methods

class openalea.oalab.gui.menu.PanedMenu(parent=None)

A widget that tries to mimic menu of Microsoft Office 2010. Cf. Ribbon Bar.

>>> from openalea.oalab.gui.menu import PanedMenu
>>> menu = PanedMenu()
addBtnByAction(pane_name, group_name, action, btn_type=0)
Parameters:
  • pane_name -- name of pane. type:String.
  • group_name -- name of group inside the pane. type:String.
  • action -- to add (with a name and an icon)
  • btn_type -- type of button to add. 0 = Big Button. 1 = Small Button, smallwidget = Small Widget, bigwidget = Big Widget. Default=0.
Returns:

created button. type:QToolButton