magicclass.widgets package

Subpackages

Submodules

magicclass.widgets.color module

class magicclass.widgets.color.QColorEdit(parent=None, value: str = 'white')[source]

Bases: PyQt5.QtWidgets.QWidget

color()[source]

Return the current color.

colorChanged
setColor(color)[source]

Set value as the current color.

class magicclass.widgets.color.QColorLineEdit(parent=None)[source]

Bases: PyQt5.QtWidgets.QLineEdit

getQColor() PyQt5.QtGui.QColor[source]

Get color as QColor object

setColor(color: QColor | str)[source]
setText(color: str | Iterable[float])[source]

Set the text of the lineEdit using any ColorType.

Colors will be converted to standard SVG spec names if possible, or shown as #RGBA hex if not.

Parameters

color (ColorType) -- Can be any ColorType recognized by our utils.colormaps.standardize_color.transform_color function.

class magicclass.widgets.color.QColorSlider(parent=None, value='white')[source]

Bases: PyQt5.QtWidgets.QWidget

addSlider(label: str)[source]
color()[source]

Return the current color.

colorChanged
setColor(color)[source]

Set value as the current color.

class magicclass.widgets.color.QColorSwatch(parent=None)[source]

Bases: PyQt5.QtWidgets.QFrame

colorChanged
getQColor() PyQt5.QtGui.QColor[source]
heightForWidth(self, int) int[source]
mouseReleaseEvent(event)[source]

Show QColorPopup picker when the user clicks on the swatch.

setColor(color: PyQt5.QtGui.QColor) None[source]
class magicclass.widgets.color.QDoubleSlider(parent=None, decimals: int = 3)[source]

Bases: PyQt5.QtWidgets.QSlider

changed
doubleValueChanged()[source]
setMaximum(self, int)[source]
setMinimum(self, int)[source]
setSingleStep(self, int)[source]
setValue(self, int)[source]
singleStep(self) int[source]
value(self) int[source]
magicclass.widgets.color.qcolor_to_rgba(qcolor: PyQt5.QtGui.QColor) tuple[float, float, float, float][source]
magicclass.widgets.color.rgba_to_html(rgba: Iterable[float]) str[source]
magicclass.widgets.color.rgba_to_qcolor(rgba: Iterable[float]) PyQt5.QtGui.QColor[source]

magicclass.widgets.containers module

magicclass.widgets.containers.wrap_container(cls: type[C] = None, base: type = None) Callable | type[C][source]

Provide a wrapper for a new container widget with a new protocol.

magicclass.widgets.misc module

class magicclass.widgets.misc.CheckButton(text: str | None = None, **kwargs)[source]

Bases: magicgui.widgets.PushButton

A checkable button.

class magicclass.widgets.misc.ConsoleTextEdit(*args, **kwargs)[source]

Bases: magicgui.widgets.TextEdit

A text edit with console-like setting.

append(text: str)[source]

Append new text.

erase_last()[source]

Erase the last line.

property selected: str

Return selected string.

property tab_size
class magicclass.widgets.misc.Figure(nrows: int = 1, ncols: int = 1, figsize: tuple[int, int] = (4, 3), style=None, **kwargs)[source]

Bases: magicclass.widgets.utils.FreeWidget

A matplotlib figure canvas.

property ax: Axes
property axes: list[Axes]
cla()[source]

Copy of plt.cla.

clf()[source]

Copy of plt.clf.

draw()[source]

Copy of plt.draw().

hist(*args, **kwargs)[source]

Copy of plt.hist.

imshow(*args, **kwargs) Axes[source]

Copy of plt.imshow.

legend(*args, **kwargs)[source]

Copy of plt.legend.

plot(*args, **kwargs) Axes[source]

Copy of plt.plot.

scatter(*args, **kwargs) Axes[source]

Copy of plt.scatter.

text(*args, **kwargs)[source]

Copy of plt.text.

title(*args, **kwargs)[source]

Copy of plt.title.

xlabel(*args, **kwargs)[source]

Copy of plt.xlabel.

xlim(*args, **kwargs)[source]

Copy of plt.xlim.

xticks(ticks=None, labels=None, **kwargs)[source]

Copy of plt.xticks.

ylabel(*args, **kwargs)[source]

Copy of plt.ylabel.

ylim(*args, **kwargs)[source]

Copy of plt.ylim.

yticks(ticks=None, labels=None, **kwargs)[source]

Copy of plt.xticks.

class magicclass.widgets.misc.SpreadSheet[source]

Bases: magicclass.widgets.utils.FreeWidget, MutableSequence[magicgui.widgets._table.Table]

A simple spread sheet widget.

index(value[, start[, stop]]) integer -- return first index of value.[source]

Raises ValueError if the value is not present.

Supporting start and stop arguments is optional, but recommended.

insert(key: int, value)[source]

S.insert(index, value) -- insert value before index

rename(index: int, name: str)[source]

magicclass.widgets.separator module

class magicclass.widgets.separator.Separator(orientation: str = 'horizontal', text: str = '', name: str = '', button: bool = False)[source]

Bases: magicclass.widgets.utils.FreeWidget

A Separator widget that can be used in both widgets and menus. This widget is not actually added to menus or toolbars.

btn_clicked

Signal descriptor, for declaring a signal on a class.

This is designed to be used as a class attribute, with the supported signature(s) provided in the contructor:

class MyEmitter:

changed = Signal(int) # changed will emit an int

def receiver(arg: int):

print("new value:", arg)

emitter = MyEmitter() emitter.changed.connect(receiver) emitter.emit(1)

Note: in the example above, MyEmitter.changed is an instance of Signal, and emitter.changed is an instance of SignalInstance.

Parameters
  • *types (sequence of Type) -- A sequence of individual types

  • description (str, optional) -- Optional descriptive text for the signal. (not used internally).

  • name (str, optional) -- Optional name of the signal. If it is not specified then the name of the class attribute that is bound to the signal will be used. default None

  • check_nargs_on_connect (str, optional) -- Whether to check the number of positional args against signature when connecting a new callback. This can also be provided at connection time using .connect(..., check_nargs=True). By default, True.

  • check_types_on_connect (str, optional) -- Whether to check the callback parameter types against signature when connecting a new callback. This can also be provided at connection time using .connect(..., check_types=True). By default, False.

property btn_text

magicclass.widgets.sequence module

class magicclass.widgets.sequence.ListDataView(obj: magicgui.widgets.ListEdit)[source]

Bases: object

Data view of ListEdit.

magicclass.widgets.utils module

class magicclass.widgets.utils.FreeWidget(layout='vertical', **kwargs)[source]

Bases: magicgui.widgets._bases.widget.Widget

A Widget class with any QWidget as a child.

set_contextmenu(contextmenugui: ContextMenuGui)[source]
set_widget(widget: PyQt5.QtWidgets.QWidget, *args)[source]

Set the central widget to the widget.

magicclass.widgets.utils.magicwidget(qcls: type[PyQt5.QtWidgets.QWidget])[source]
magicclass.widgets.utils.merge_super_sigs(cls)[source]

Module contents

Advanced widgets for magic class GUI. These widgets are all compatible with the append method of Container widgets.

class magicclass.widgets.ButtonContainer(name: str = '', annotation: Any = None, label: str = None, tooltip: str | None = None, visible: bool | None = None, enabled: bool = True, gui_only=False, backend_kwargs={}, layout: str = 'vertical', widgets: Sequence[Widget] = (), labels=True)

Bases: magicgui.widgets._bases.widget.Widget, magicgui.widgets._bases.mixins._OrientationMixin, MutableSequence[magicgui.widgets._bases.widget.Widget]

A Container Widget hidden in a button.

Parameters
  • name (str) -- The name of the parameter represented by this widget. by default ""

  • annotation (Any) -- The type annotation for the parameter represented by the widget, by default None

  • label (str) -- A string to use for an associated Label widget (if this widget is being shown in a Container widget, and labels are on). By default, name will be used. Note: name refers the name of the parameter, as might be used in a signature, whereas label is just the label for that widget in the GUI.

  • tooltip (str) -- A tooltip to display when hovering over the widget.

  • visible (bool) -- Whether the widget is visible, by default True.

  • backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.

property btn_text
property text
class magicclass.widgets.CheckButton(text: str | None = None, **kwargs)[source]

Bases: magicgui.widgets.PushButton

A checkable button.

class magicclass.widgets.CollapsibleContainer(name: str = '', annotation: Any = None, label: str = None, tooltip: str | None = None, visible: bool | None = None, enabled: bool = True, gui_only=False, backend_kwargs={}, layout: str = 'vertical', widgets: Sequence[Widget] = (), labels=True)

Bases: magicgui.widgets._bases.widget.Widget, magicgui.widgets._bases.mixins._OrientationMixin, MutableSequence[magicgui.widgets._bases.widget.Widget]

A collapsible Container Widget.

Parameters
  • name (str) -- The name of the parameter represented by this widget. by default ""

  • annotation (Any) -- The type annotation for the parameter represented by the widget, by default None

  • label (str) -- A string to use for an associated Label widget (if this widget is being shown in a Container widget, and labels are on). By default, name will be used. Note: name refers the name of the parameter, as might be used in a signature, whereas label is just the label for that widget in the GUI.

  • tooltip (str) -- A tooltip to display when hovering over the widget.

  • visible (bool) -- Whether the widget is visible, by default True.

  • backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.

property btn_text
property collapsed: bool
property text
class magicclass.widgets.ColorEdit(name: str = '', annotation: Any = None, label: str = None, tooltip: str | None = None, visible: bool | None = None, enabled: bool = True, gui_only=False, backend_kwargs={}, value: Any = UNSET, bind: Any = UNSET, nullable=False)

Bases: magicgui.widgets._bases.value_widget.ValueWidget

A widget for editing colors.

Parameters
  • name (str) -- The name of the parameter represented by this widget. by default ""

  • annotation (Any) -- The type annotation for the parameter represented by the widget, by default None

  • label (str) -- A string to use for an associated Label widget (if this widget is being shown in a Container widget, and labels are on). By default, name will be used. Note: name refers the name of the parameter, as might be used in a signature, whereas label is just the label for that widget in the GUI.

  • tooltip (str) -- A tooltip to display when hovering over the widget.

  • visible (bool) -- Whether the widget is visible, by default True.

  • backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.

  • value (tuple of float or str) -- The starting value for the widget.

  • bind (Any) -- A value or callback to bind this widget, then whenever widget.value is accessed, the value provided here will be returned. value can be a callable, in which case value(self) will be returned (i.e. your callback must accept a single parameter, which is this widget instance.).

  • value -- RGBA color, color code or standard color name.

class magicclass.widgets.ColorSlider(name: str = '', annotation: Any = None, label: str = None, tooltip: str | None = None, visible: bool | None = None, enabled: bool = True, gui_only=False, backend_kwargs={}, value: Any = UNSET, bind: Any = UNSET, nullable=False)

Bases: magicgui.widgets._bases.value_widget.ValueWidget

A multi-slider for editing colors.

Parameters
  • name (str) -- The name of the parameter represented by this widget. by default ""

  • annotation (Any) -- The type annotation for the parameter represented by the widget, by default None

  • label (str) -- A string to use for an associated Label widget (if this widget is being shown in a Container widget, and labels are on). By default, name will be used. Note: name refers the name of the parameter, as might be used in a signature, whereas label is just the label for that widget in the GUI.

  • tooltip (str) -- A tooltip to display when hovering over the widget.

  • visible (bool) -- Whether the widget is visible, by default True.

  • backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.

  • value (tuple of float or str) -- The starting value for the widget.

  • bind (Any) -- A value or callback to bind this widget, then whenever widget.value is accessed, the value provided here will be returned. value can be a callable, in which case value(self) will be returned (i.e. your callback must accept a single parameter, which is this widget instance.).

  • value -- RGBA color, color code or standard color name.

class magicclass.widgets.ConsoleTextEdit(*args, **kwargs)[source]

Bases: magicgui.widgets.TextEdit

A text edit with console-like setting.

append(text: str)[source]

Append new text.

erase_last()[source]

Erase the last line.

property selected: str

Return selected string.

property tab_size
class magicclass.widgets.DictWidget(value=None, **kwargs)[source]

Bases: magicclass.widgets.pywidgets.object.BaseWidget, MutableMapping

clear() None[source]

Clear dictionary contents.

get(k[, d]) D[k] if k in D, else d.  d defaults to None.[source]
items() magicclass.widgets.pywidgets.dict.DictItemView[source]

Return the view of dictionary keys and values as strings and Python objects.

keys()[source]

Return the view of dictionary keys.

pop(k: str)[source]

Pop a dictionary content.

update(d: dict[str, typing.Any])[source]

Update the dictionary contents.

property value: dict[str, typing.Any]
values() magicclass.widgets.pywidgets.dict.DictValueView[source]

Return the view of dictionary values as Python objects.

class magicclass.widgets.DraggableContainer(name: str = '', annotation: Any = None, label: str = None, tooltip: str | None = None, visible: bool | None = None, enabled: bool = True, gui_only=False, backend_kwargs={}, layout: str = 'vertical', widgets: Sequence[Widget] = (), labels=True)

Bases: magicgui.widgets._bases.widget.Widget, magicgui.widgets._bases.mixins._OrientationMixin, MutableSequence[magicgui.widgets._bases.widget.Widget]

A draggable Container Widget.

Parameters
  • name (str) -- The name of the parameter represented by this widget. by default ""

  • annotation (Any) -- The type annotation for the parameter represented by the widget, by default None

  • label (str) -- A string to use for an associated Label widget (if this widget is being shown in a Container widget, and labels are on). By default, name will be used. Note: name refers the name of the parameter, as might be used in a signature, whereas label is just the label for that widget in the GUI.

  • tooltip (str) -- A tooltip to display when hovering over the widget.

  • visible (bool) -- Whether the widget is visible, by default True.

  • backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.

class magicclass.widgets.Figure(nrows: int = 1, ncols: int = 1, figsize: tuple[int, int] = (4, 3), style=None, **kwargs)[source]

Bases: magicclass.widgets.utils.FreeWidget

A matplotlib figure canvas.

property ax: Axes
property axes: list[Axes]
cla()[source]

Copy of plt.cla.

clf()[source]

Copy of plt.clf.

draw()[source]

Copy of plt.draw().

hist(*args, **kwargs)[source]

Copy of plt.hist.

imshow(*args, **kwargs) Axes[source]

Copy of plt.imshow.

legend(*args, **kwargs)[source]

Copy of plt.legend.

plot(*args, **kwargs) Axes[source]

Copy of plt.plot.

scatter(*args, **kwargs) Axes[source]

Copy of plt.scatter.

text(*args, **kwargs)[source]

Copy of plt.text.

title(*args, **kwargs)[source]

Copy of plt.title.

xlabel(*args, **kwargs)[source]

Copy of plt.xlabel.

xlim(*args, **kwargs)[source]

Copy of plt.xlim.

xticks(ticks=None, labels=None, **kwargs)[source]

Copy of plt.xticks.

ylabel(*args, **kwargs)[source]

Copy of plt.ylabel.

ylim(*args, **kwargs)[source]

Copy of plt.ylim.

yticks(ticks=None, labels=None, **kwargs)[source]

Copy of plt.xticks.

class magicclass.widgets.FrameContainer(name: str = '', annotation: Any = None, label: str = None, tooltip: str | None = None, visible: bool | None = None, enabled: bool = True, gui_only=False, backend_kwargs={}, layout: str = 'vertical', widgets: Sequence[Widget] = (), labels=True)

Bases: magicgui.widgets._bases.widget.Widget, magicgui.widgets._bases.mixins._OrientationMixin, MutableSequence[magicgui.widgets._bases.widget.Widget]

A QGroupBox like container without title.

Parameters
  • name (str) -- The name of the parameter represented by this widget. by default ""

  • annotation (Any) -- The type annotation for the parameter represented by the widget, by default None

  • label (str) -- A string to use for an associated Label widget (if this widget is being shown in a Container widget, and labels are on). By default, name will be used. Note: name refers the name of the parameter, as might be used in a signature, whereas label is just the label for that widget in the GUI.

  • tooltip (str) -- A tooltip to display when hovering over the widget.

  • visible (bool) -- Whether the widget is visible, by default True.

  • backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.

class magicclass.widgets.FreeWidget(layout='vertical', **kwargs)[source]

Bases: magicgui.widgets._bases.widget.Widget

A Widget class with any QWidget as a child.

set_contextmenu(contextmenugui: ContextMenuGui)[source]
set_widget(widget: PyQt5.QtWidgets.QWidget, *args)[source]

Set the central widget to the widget.

class magicclass.widgets.GroupBoxContainer(name: str = '', annotation: Any = None, label: str = None, tooltip: str | None = None, visible: bool | None = None, enabled: bool = True, gui_only=False, backend_kwargs={}, layout: str = 'vertical', widgets: Sequence[Widget] = (), labels=True)

Bases: magicgui.widgets._bases.widget.Widget, magicgui.widgets._bases.mixins._OrientationMixin, MutableSequence[magicgui.widgets._bases.widget.Widget]

A QGroupBox like container

Parameters
  • name (str) -- The name of the parameter represented by this widget. by default ""

  • annotation (Any) -- The type annotation for the parameter represented by the widget, by default None

  • label (str) -- A string to use for an associated Label widget (if this widget is being shown in a Container widget, and labels are on). By default, name will be used. Note: name refers the name of the parameter, as might be used in a signature, whereas label is just the label for that widget in the GUI.

  • tooltip (str) -- A tooltip to display when hovering over the widget.

  • visible (bool) -- Whether the widget is visible, by default True.

  • backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.

property name
class magicclass.widgets.HCollapsibleContainer(name: str = '', annotation: Any = None, label: str = None, tooltip: str | None = None, visible: bool | None = None, enabled: bool = True, gui_only=False, backend_kwargs={}, layout: str = 'vertical', widgets: Sequence[Widget] = (), labels=True)

Bases: magicgui.widgets._bases.widget.Widget, magicgui.widgets._bases.mixins._OrientationMixin, MutableSequence[magicgui.widgets._bases.widget.Widget]

A collapsible Container Widget.

Parameters
  • name (str) -- The name of the parameter represented by this widget. by default ""

  • annotation (Any) -- The type annotation for the parameter represented by the widget, by default None

  • label (str) -- A string to use for an associated Label widget (if this widget is being shown in a Container widget, and labels are on). By default, name will be used. Note: name refers the name of the parameter, as might be used in a signature, whereas label is just the label for that widget in the GUI.

  • tooltip (str) -- A tooltip to display when hovering over the widget.

  • visible (bool) -- Whether the widget is visible, by default True.

  • backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.

property collapsed: bool
class magicclass.widgets.ListContainer(name: str = '', annotation: Any = None, label: str = None, tooltip: str | None = None, visible: bool | None = None, enabled: bool = True, gui_only=False, backend_kwargs={}, layout: str = 'vertical', widgets: Sequence[Widget] = (), labels=True)

Bases: magicgui.widgets._bases.widget.Widget, magicgui.widgets._bases.mixins._OrientationMixin, MutableSequence[magicgui.widgets._bases.widget.Widget]

A Container Widget that support drag and drop.

Parameters
  • name (str) -- The name of the parameter represented by this widget. by default ""

  • annotation (Any) -- The type annotation for the parameter represented by the widget, by default None

  • label (str) -- A string to use for an associated Label widget (if this widget is being shown in a Container widget, and labels are on). By default, name will be used. Note: name refers the name of the parameter, as might be used in a signature, whereas label is just the label for that widget in the GUI.

  • tooltip (str) -- A tooltip to display when hovering over the widget.

  • visible (bool) -- Whether the widget is visible, by default True.

  • backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.

property current_index
class magicclass.widgets.ListEdit(name: str = '', annotation: Any = None, label: str = None, tooltip: str | None = None, visible: bool | None = None, enabled: bool = True, gui_only=False, backend_kwargs={}, layout: str = 'horizontal', widgets: Sequence[Widget] = (), labels=True, value: Iterable[_V] | _Unset = UNSET, nullable: bool = False, options: WidgetOptions = None)

Bases: magicgui.widgets._bases.widget.Widget, magicgui.widgets._bases.mixins._OrientationMixin, MutableSequence[magicgui.widgets._bases.widget.Widget]

A widget to represent a list of values.

A ListEdit container can create a list with multiple objects of same type. It will contain many child widgets and their value is represented as a Python list object. If a list is given as the initial value, types of child widgets are determined from the contents. Number of contents can be adjusted with +/- buttons.

Parameters
  • name (str) -- The name of the parameter represented by this widget. by default ""

  • annotation (Any) -- The type annotation for the parameter represented by the widget, by default None

  • label (str) -- A string to use for an associated Label widget (if this widget is being shown in a Container widget, and labels are on). By default, name will be used. Note: name refers the name of the parameter, as might be used in a signature, whereas label is just the label for that widget in the GUI.

  • tooltip (str) -- A tooltip to display when hovering over the widget.

  • visible (bool) -- Whether the widget is visible, by default True.

  • backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.

  • name -- The name of the parameter represented by this widget. by default ""

  • annotation -- The type annotation for the parameter represented by the widget, by default None

  • label -- A string to use for an associated Label widget (if this widget is being shown in a Container widget, and labels are on). By default, name will be used. Note: name refers the name of the parameter, as might be used in a signature, whereas label is just the label for that widget in the GUI.

  • tooltip -- A tooltip to display when hovering over the widget.

  • visible -- Whether the widget is visible, by default True.

  • backend_kwargs -- keyword argument to pass to the backend widget constructor.

  • options (WidgetOptions) -- Widget options of child widgets.

property annotation

Return type annotation for the parameter represented by the widget. ForwardRefs will be resolve when setting the annotation. For ListEdit, annotation will be like 'list[str]'.

property data: magicclass.widgets.sequence.ListDataView

Return a data view of current value.

property value: list

Return current value as a list object.

class magicclass.widgets.ListWidget(value: Optional[Iterable[Any]] = None, dragdrop: bool = True, **kwargs)[source]

Bases: magicclass.widgets.pywidgets.object.BaseWidget, MutableSequence

clear()[source]

Clear all the items.

index(obj: Any, start: int = 0, stop: Optional[int] = None) int[source]

Find object or list widget item from the list widget.

Parameters
  • obj (Any) -- Object to find. If a PyListWidgetItem is given, the index of the item (not the tagged object) is searched for.

  • start (int, optional) -- Starting index, by default 0

  • stop (int, optional) -- Index to stop searching.

Returns

Index of object.

Return type

int

Raises

ValueError -- If object was not found.

insert(i: int, obj: Any)[source]

Insert object of any type to the list.

property value: list[typing.Any]

Get all the contents as a Python list.

Returns

Contents of the list widget.

Return type

list

class magicclass.widgets.OptionalWidget(name: str = '', annotation: Any = None, label: str = None, tooltip: str | None = None, visible: bool | None = None, enabled: bool = True, gui_only=False, backend_kwargs={}, layout='vertical', widgets: Sequence[Widget] = (), labels=True, text: str = None, nullable=True, value=UNSET, options=None)

Bases: magicgui.widgets._bases.widget.Widget, magicgui.widgets._bases.mixins._OrientationMixin, MutableSequence[magicgui.widgets._bases.widget.Widget]

A container that can represent optional argument.

Parameters
  • name (str) -- The name of the parameter represented by this widget. by default ""

  • annotation (Any) -- The type annotation for the parameter represented by the widget, by default None

  • label (str) -- A string to use for an associated Label widget (if this widget is being shown in a Container widget, and labels are on). By default, name will be used. Note: name refers the name of the parameter, as might be used in a signature, whereas label is just the label for that widget in the GUI.

  • tooltip (str) -- A tooltip to display when hovering over the widget.

  • visible (bool) -- Whether the widget is visible, by default True.

  • backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.

  • name -- The name of the parameter represented by this widget. by default ""

  • annotation -- The type annotation for the parameter represented by the widget, by default None

  • label -- A string to use for an associated Label widget (if this widget is being shown in a Container widget, and labels are on). By default, name will be used. Note: name refers the name of the parameter, as might be used in a signature, whereas label is just the label for that widget in the GUI.

  • tooltip -- A tooltip to display when hovering over the widget.

  • visible -- Whether the widget is visible, by default True.

  • backend_kwargs -- keyword argument to pass to the backend widget constructor.

  • text (str) -- Text of checkbox.

  • value (Any) -- Initial value.

  • options (dict) -- Widget options of the inner value widget.

property text: str
property value: Any
class magicclass.widgets.ScrollableContainer(name: str = '', annotation: Any = None, label: str = None, tooltip: str | None = None, visible: bool | None = None, enabled: bool = True, gui_only=False, backend_kwargs={}, layout: str = 'vertical', widgets: Sequence[Widget] = (), labels=True)

Bases: magicgui.widgets._bases.widget.Widget, magicgui.widgets._bases.mixins._OrientationMixin, MutableSequence[magicgui.widgets._bases.widget.Widget]

A scrollable Container Widget.

Parameters
  • name (str) -- The name of the parameter represented by this widget. by default ""

  • annotation (Any) -- The type annotation for the parameter represented by the widget, by default None

  • label (str) -- A string to use for an associated Label widget (if this widget is being shown in a Container widget, and labels are on). By default, name will be used. Note: name refers the name of the parameter, as might be used in a signature, whereas label is just the label for that widget in the GUI.

  • tooltip (str) -- A tooltip to display when hovering over the widget.

  • visible (bool) -- Whether the widget is visible, by default True.

  • backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.

class magicclass.widgets.Separator(orientation: str = 'horizontal', text: str = '', name: str = '', button: bool = False)[source]

Bases: magicclass.widgets.utils.FreeWidget

A Separator widget that can be used in both widgets and menus. This widget is not actually added to menus or toolbars.

btn_clicked

Signal descriptor, for declaring a signal on a class.

This is designed to be used as a class attribute, with the supported signature(s) provided in the contructor:

class MyEmitter:

changed = Signal(int) # changed will emit an int

def receiver(arg: int):

print("new value:", arg)

emitter = MyEmitter() emitter.changed.connect(receiver) emitter.emit(1)

Note: in the example above, MyEmitter.changed is an instance of Signal, and emitter.changed is an instance of SignalInstance.

Parameters
  • *types (sequence of Type) -- A sequence of individual types

  • description (str, optional) -- Optional descriptive text for the signal. (not used internally).

  • name (str, optional) -- Optional name of the signal. If it is not specified then the name of the class attribute that is bound to the signal will be used. default None

  • check_nargs_on_connect (str, optional) -- Whether to check the number of positional args against signature when connecting a new callback. This can also be provided at connection time using .connect(..., check_nargs=True). By default, True.

  • check_types_on_connect (str, optional) -- Whether to check the callback parameter types against signature when connecting a new callback. This can also be provided at connection time using .connect(..., check_types=True). By default, False.

property btn_text
central_widget: QWidget
name: str
class magicclass.widgets.SplitterContainer(name: str = '', annotation: Any = None, label: str = None, tooltip: str | None = None, visible: bool | None = None, enabled: bool = True, gui_only=False, backend_kwargs={}, layout: str = 'vertical', widgets: Sequence[Widget] = (), labels=True)

Bases: magicgui.widgets._bases.widget.Widget, magicgui.widgets._bases.mixins._OrientationMixin, MutableSequence[magicgui.widgets._bases.widget.Widget]

A Container equipped with splitter

Parameters
  • name (str) -- The name of the parameter represented by this widget. by default ""

  • annotation (Any) -- The type annotation for the parameter represented by the widget, by default None

  • label (str) -- A string to use for an associated Label widget (if this widget is being shown in a Container widget, and labels are on). By default, name will be used. Note: name refers the name of the parameter, as might be used in a signature, whereas label is just the label for that widget in the GUI.

  • tooltip (str) -- A tooltip to display when hovering over the widget.

  • visible (bool) -- Whether the widget is visible, by default True.

  • backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.

class magicclass.widgets.SpreadSheet[source]

Bases: magicclass.widgets.utils.FreeWidget, MutableSequence[magicgui.widgets._table.Table]

A simple spread sheet widget.

index(value[, start[, stop]]) integer -- return first index of value.[source]

Raises ValueError if the value is not present.

Supporting start and stop arguments is optional, but recommended.

insert(key: int, value)[source]

S.insert(index, value) -- insert value before index

rename(index: int, name: str)[source]
class magicclass.widgets.StackedContainer(name: str = '', annotation: Any = None, label: str = None, tooltip: str | None = None, visible: bool | None = None, enabled: bool = True, gui_only=False, backend_kwargs={}, layout: str = 'vertical', widgets: Sequence[Widget] = (), labels=True)

Bases: magicgui.widgets._bases.widget.Widget, magicgui.widgets._bases.mixins._OrientationMixin, MutableSequence[magicgui.widgets._bases.widget.Widget]

A stacked Container Widget

Parameters
  • name (str) -- The name of the parameter represented by this widget. by default ""

  • annotation (Any) -- The type annotation for the parameter represented by the widget, by default None

  • label (str) -- A string to use for an associated Label widget (if this widget is being shown in a Container widget, and labels are on). By default, name will be used. Note: name refers the name of the parameter, as might be used in a signature, whereas label is just the label for that widget in the GUI.

  • tooltip (str) -- A tooltip to display when hovering over the widget.

  • visible (bool) -- Whether the widget is visible, by default True.

  • backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.

property current_index
class magicclass.widgets.SubWindowsContainer(name: str = '', annotation: Any = None, label: str = None, tooltip: str | None = None, visible: bool | None = None, enabled: bool = True, gui_only=False, backend_kwargs={}, layout: str = 'vertical', widgets: Sequence[Widget] = (), labels=True)

Bases: magicgui.widgets._bases.widget.Widget, magicgui.widgets._bases.mixins._OrientationMixin, MutableSequence[magicgui.widgets._bases.widget.Widget]

A window-in-window container

Parameters
  • name (str) -- The name of the parameter represented by this widget. by default ""

  • annotation (Any) -- The type annotation for the parameter represented by the widget, by default None

  • label (str) -- A string to use for an associated Label widget (if this widget is being shown in a Container widget, and labels are on). By default, name will be used. Note: name refers the name of the parameter, as might be used in a signature, whereas label is just the label for that widget in the GUI.

  • tooltip (str) -- A tooltip to display when hovering over the widget.

  • visible (bool) -- Whether the widget is visible, by default True.

  • backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.

class magicclass.widgets.TabbedContainer(name: str = '', annotation: Any = None, label: str = None, tooltip: str | None = None, visible: bool | None = None, enabled: bool = True, gui_only=False, backend_kwargs={}, layout: str = 'vertical', widgets: Sequence[Widget] = (), labels=True)

Bases: magicgui.widgets._bases.widget.Widget, magicgui.widgets._bases.mixins._OrientationMixin, MutableSequence[magicgui.widgets._bases.widget.Widget]

A tab categorized Container Widget.

Parameters
  • name (str) -- The name of the parameter represented by this widget. by default ""

  • annotation (Any) -- The type annotation for the parameter represented by the widget, by default None

  • label (str) -- A string to use for an associated Label widget (if this widget is being shown in a Container widget, and labels are on). By default, name will be used. Note: name refers the name of the parameter, as might be used in a signature, whereas label is just the label for that widget in the GUI.

  • tooltip (str) -- A tooltip to display when hovering over the widget.

  • visible (bool) -- Whether the widget is visible, by default True.

  • backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.

property current_index
class magicclass.widgets.ToolBoxContainer(name: str = '', annotation: Any = None, label: str = None, tooltip: str | None = None, visible: bool | None = None, enabled: bool = True, gui_only=False, backend_kwargs={}, layout: str = 'vertical', widgets: Sequence[Widget] = (), labels=True)

Bases: magicgui.widgets._bases.widget.Widget, magicgui.widgets._bases.mixins._OrientationMixin, MutableSequence[magicgui.widgets._bases.widget.Widget]

A Tool box Widget.

Parameters
  • name (str) -- The name of the parameter represented by this widget. by default ""

  • annotation (Any) -- The type annotation for the parameter represented by the widget, by default None

  • label (str) -- A string to use for an associated Label widget (if this widget is being shown in a Container widget, and labels are on). By default, name will be used. Note: name refers the name of the parameter, as might be used in a signature, whereas label is just the label for that widget in the GUI.

  • tooltip (str) -- A tooltip to display when hovering over the widget.

  • visible (bool) -- Whether the widget is visible, by default True.

  • backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.

property current_index
class magicclass.widgets.TupleEdit(name: str = '', annotation: Any = None, label: str = None, tooltip: str | None = None, visible: bool | None = None, enabled: bool = True, gui_only=False, backend_kwargs={}, layout: str = 'horizontal', widgets: Sequence[Widget] = (), labels=True, value: Iterable[_V] | _Unset = UNSET, nullable: bool = False, options: WidgetOptions = None)

Bases: magicgui.widgets._bases.widget.Widget, magicgui.widgets._bases.mixins._OrientationMixin, MutableSequence[magicgui.widgets._bases.widget.Widget]

A widget to represent a tuple of values.

A TupleEdit container has several child widgets of different type. Their value is represented as a Python tuple object. If a tuple is given as the initial value, types of child widgets are determined one by one. Unlike ListEdit, number of contents is not editable.

Parameters
  • name (str) -- The name of the parameter represented by this widget. by default ""

  • annotation (Any) -- The type annotation for the parameter represented by the widget, by default None

  • label (str) -- A string to use for an associated Label widget (if this widget is being shown in a Container widget, and labels are on). By default, name will be used. Note: name refers the name of the parameter, as might be used in a signature, whereas label is just the label for that widget in the GUI.

  • tooltip (str) -- A tooltip to display when hovering over the widget.

  • visible (bool) -- Whether the widget is visible, by default True.

  • backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.

  • name -- The name of the parameter represented by this widget. by default ""

  • annotation -- The type annotation for the parameter represented by the widget, by default None

  • label -- A string to use for an associated Label widget (if this widget is being shown in a Container widget, and labels are on). By default, name will be used. Note: name refers the name of the parameter, as might be used in a signature, whereas label is just the label for that widget in the GUI.

  • tooltip -- A tooltip to display when hovering over the widget.

  • visible -- Whether the widget is visible, by default True.

  • backend_kwargs -- keyword argument to pass to the backend widget constructor.

  • options (WidgetOptions) -- Widget options of child widgets.

property annotation

Return type annotation for the parameter represented by the widget. ForwardRefs will be resolve when setting the annotation. For TupleEdit, annotation will be like 'tuple[str, int]'.

property value: tuple

Return current value as a tuple.