Widgets

class mpl_widget_box.widgets.Label(wid, label, pad=None, draw_frame=True, auxinfo=None, fixed_width=None, textprops=None, align='left', **kwargs)

A widget where you can place text or other box.

Parameters
  • wid (str) – The widget ID.

  • label (str or OffsetBox) – The label string or an instance of OffsetBox to be displayed

  • fixed_width (float) – the width of the label. When None, the width will be calculated based on the rendered length of the string. Default is None.

  • textprops (dict) – text properties to be set. Default is None.

  • align (str) – dicrection to align the text. ‘left’, ‘center’ or ‘right’. Default is ‘left’.

  • auxinfo (dict) – auxilary information to be returned with status. Default is empty dict.

Examples

>>> l1 = W.Label("lbl", "Label")
>>> install_widgets_simple(ax, [l1])
get_label()

get the label string.

set_label(l)

set the label string.

class mpl_widget_box.widgets.Button(wid, label, textprops=None, contextual_theme=None, expand=False, align='', pad=3.0, tooltip=None, **kwargs)

A widget you can click.

Parameters
  • wid (str) – The widget ID.

  • label (str or OffsetBox) – The label string or an instance of OffsetBox to be displayed

  • textprops (dict) – text properties to be set. Default is None.

  • contextual_theme (dict) –

  • expand (bool) – expand the button frame if True. Default if False.

  • align (str) – dicrection to align the text. ‘left’, ‘center’ or ‘right’. Default is ‘left’.

  • tooltip (str) –

Examples

>>> b1 = W.Button("btn", "Button")
>>> install_widgets_simple(ax, [b1])
set_contextual_theme(themes)

set contextual theme for the button.

Examples

>>> b1 = W.Button("btn", "Button")
>>> theme = {
    "default": dict(fc="#6200cc", ec="#6200ee"),
    "default-hover": dict(fc="#6200ee", ec="#6200ee"),
    "disabled": dict(fc="#cccccc", ec="#cccccc"),
    "disabled-hover": dict(fc="#cccccc", ec="#cccccc")}
>>> b1.set_contextual_theme(theme)
class mpl_widget_box.widgets.Radio(wid, labels, selected=None, values=None, title=None, tooltips=None, pad=3, direction='v')

Radio buttons.

Parameters
  • wid (str) – The widget ID.

  • labels (list of str) – The label strings

  • selected (int) –

  • values (list) – list of values associated with the labels. The staus will include the value of currently selected item.

  • title (str) –

  • tooltips (str) –

  • direction (str) – The direction of radio items will be packed. ‘v’ or ‘h’. Default is ‘v’.

Examples

>>> r1 = W.Radio("radio", ["Sel 1", "Sel2", "Sel 3"])
>>> install_widgets_simple(ax, [r1])
select(i)

Select the item

Parameters

i (int) – select the i-th item. If i is larger than len(values) or smaller than 0, it will automatically wrapped around.

class mpl_widget_box.widgets.CheckBox(wid, labels, selected=None, values=None, title=None, tooltips=None, pad=3, direction='v')

Checkbox.

Parameters
  • wid (str) – The widget ID.

  • labels (list of str) – The label strings

  • selected (int) –

  • values (list) – list of values associated with the labels. The staus will include the value of currently selected item.

  • title (str) –

  • tooltips (str) –

  • direction (str) – The direction of radio items will be packed. ‘v’ or ‘h’. Default is ‘v’.

Examples

>>> cb1 = W.CheckBox("cb", ["Sel 1", "Sel2", "Sel 3"])
>>> install_widgets_simple(ax, [cb1])
select(i)

select (or deselect) the i-th item.