Skip to content

How to develop

yadizhou edited this page Nov 19, 2017 · 11 revisions

Overview

To understand how to create new widget, first let’s look at the class hierarchy and relationships of those core classes.

A widget is composed of attributes, behaviors, a set of anchors for input and output, a dialog for interaction, and the task it does. By subclassing Widget and Dialog class, and occasionally Anchor and BaseWidget class, we create new widgets.

Classes in blue are the ones provided by LabPype:

  • BaseWidget - Defines everything else of a widget except for the components we just mentioned.
  • Widget - A subclass of BaseWidget that tells the base class how to behave. This built-in child class of BaseWidget is a 5-state state machine that is sufficient for most cases.
  • Anchor - Represent a data field. It is used for building connections between widgets.
  • Dialog - The superclass of all dialogs that are associated with widgets. It has many useful functions to make it simple for us to create dialogs.

Classes in green are the ones we would normally subclass. Subclass the Widget class, then specify a few class attributes and implement the task, we get a new widget. Among the class attributes, INCOMING and OUTGOING are the ones that specify the data type for input and output. They are by default instances of Anchor, which we do not need to subclass in most cases. Another attribute DIALOG specifies what dialog class should be used for interacting with this widget. If the widget is simple enough, then a dialog can be generated automatically by introspection. In this case, the base class Dialog will be assigned to the widget. To start, see section Basic

Classes in yellow are the ones that we only subclass when more flexibility is needed. For example, we can create a new subclass of BaseWidget that is an 8-state state machine, so that it can have more complicated behaviors. By subclassing the Anchor, we can change how connections are made and used in the workflow. See section Advanced for more details.

Basic

TODO

Advanced

TODO