-
Notifications
You must be signed in to change notification settings - Fork 4
Class reference
labpype.widget
has the following classes for making new widgets. You can directly import them from labpype.widget
. Alternatively, you can also import them from their own modules.
The documentation of some of the classes has three parts: "Inheritance Guide", "Example", and "APIs". "Inheritance Guide" lists all the class attributes and instance methods need to be implemented when creating a subclass. "Example" shows a simple case. "APIs" lists all the useful methods that you may need when implementing the methods for the subclasses.
-
labpype.widget.widget
-
labpype.widget.dialog
-
labpype.widget.link
-
labpype.widget.field
Widget
is the common base class of all the widgets. You will need to specify some class attributes and implement some methods for the child classes to create new widgets.
For convenience, we will use the name Widget
as the class name for all the following class attributes and widget
as the corresponding object name for the methods, while they actually mean the child class that you inherit from Widget
and the object from that child class. For example, we can create a widget class called FirstWidget
whose class attribute FirstWidget.NAME
is "Awesome Widget"
. Here, FirstWidget
is the class you inherit from Widget
and whose class attributes are assigned.
class FirstWidget(Widget):
NAME = "Awesome Widget"
Note that you should never change the values of class attributes of Widget
.
Default: ""
Default: None
Default: False
Default: None
Default: None
Default: None
Default: False
Default behavior: return Widget.NAME
Default behavior: return JSON formatted str from dumping all the data
Default behavior: return the parsed JSON document
Default behavior: none
Default behavior: none
Default behavior: none
Default behavior: return False
Dialog
is the common base class of all the dialogs. You will need to specify some class attributes and implement some methods for the child classes to create new dialogs.
For convenience, we will use the name Dialog
as the class name for all the following class attributes and dialog
as the corresponding object name for the methods, while they actually mean the child class that you inherit from Dialog
and the object from that child class.
Default: True
Default: None
Default: wx.VERTICAL
Default: 2
Default: 80
Default: 20
Default behavior: none
Default behavior: add standard buttons. See Dialog.AddStdButton(sizer)
Default behavior: none
Default behavior: none
Disable the main canvas. This method is used together with dialog.EnableCanvas()
Enable the main canvas. This method is used together with dialog.DisableCanvas()
Add standard buttons to the dialog. This is the default behavior of dialog.Finalize(Sizer)
. Therefore, you normally wouln't need to call this method unless you override dialog.Finalize(Sizer)
.
dialog.AddSectionHead(sizer,
orientation=wx.HORIZONTAL,
label="",
shape="B")
dialog.AddButton(sizer,
label="",
tag="",
width=80,
onClick=None,
**kwargs)
dialog.AddButtonToggle(sizer,
label="",
tags=(),
width=80,
toggle=False,
onClick=None,
**kwargs)
dialog.AddButtonBundle(sizer,
label="",
tags=(),
width=80,
rows=1,
toggled=0,
group="",
onClick=None,
**kwargs)
dialog.AddPickerValue(sizer,
label="",
choices=(),
selected=-1,
width=80,
**kwargs)
dialog.AddStaticText(sizer,
label="",
value="",
width=-1)
dialog.AddLineCtrl(sizer,
label="",
value="",
width=-1,
style=0,
onInput=None,
hint="",
font=None)
dialog.AddTextCtrl(sizer,
label="",
value="",
width=-1,
height=-1,
style=0,
inline=True,
onInput=None,
hint="",
font=None)
dialog.AddListBox(sizer,
label="",
choices=(),
selected=-1,
width=-1,
height=-1,
onClick=None,
onDClick=None,
inline=True)
dialog.AddFilePicker(sizer,
label="",
value="",
width=-1,
mode="S",
wildcard="All files (*.*)|*.*",
style=0,
onSelect=Ab.DoNothing)
Anchor types are used for defining legit connections. A widget has one or more anchors, each anchor has an attribute aType
whose value is an anchor type class. For two anchors to be able to connect, their aType
pair should be defined to be legit beforehand.
Anchor types are empty classes used as keys in some dictionary that contains all the legit connections. The reason that a class is chosen as the key over str, int or any other hashable object is that classes are inheritable, and this feature makes it elegant to define legit links. For example, if connections between ANCHOR_STRING
and ANCHOR_SEQUENCE
is defined to be legit, then connections between ANCHOR_STRING
and ANCHOR_DNA
, or ANCHOR_STRING
and ANCHOR_PROTEIN
are also legit automatically, given that ANCHOR_DNA
and ANCHOR_PROTEIN
are subclasses of ANCHOR_SEQUENCE
.
The base class for all user-defined anchor types.
The base class for special anchor types (e.g., ANCHOR_ALL
and ANCHOR_NONE
). The connection between two special anchor types is considered not legit.
Anchors whose aType
are ANCHOR_ALL
can connect to any anchors whose aType
are subclasses of ANCHOR_REGULAR
Anchors whose aType
are ANCHOR_NONE
cannot connect to anything.
class ANCHOR_SEQUENCE(ANCHOR_REGULAR): pass
class ANCHOR_DNA(ANCHOR_SEQUENCE): pass
class ANCHOR_PROTEIN(ANCHOR_SEQUENCE): pass
BaseField(key, label, **kwargs)
BooleanField(key, label,
tag1,
tag2,
**kwargs)
LineField(key, label,
maxLength=None,
minLength=None,
**kwargs)
TextField(key, label,
maxLine=None,
minLine=None,
maxLength=None,
minLength=None,
**kwargs)
IntegerField(key, label,
maxValue=None,
minValue=None,
**kwargs)
FloatField(key, label,
maxValue=None,
minValue=None,
**kwargs)
ChoiceField(key, label,
choices=(),
widget="C",
**kwargs)