magicclass.widgets package¶
Subpackages¶
Submodules¶
magicclass.widgets.color module¶
- class magicclass.widgets.color.QColorEdit(parent=None, value: str = 'white')[source]¶
Bases:
PyQt5.QtWidgets.QWidget
- colorChanged¶
- class magicclass.widgets.color.QColorLineEdit(parent=None)[source]¶
Bases:
PyQt5.QtWidgets.QLineEdit
- 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
- colorChanged¶
- class magicclass.widgets.color.QColorSwatch(parent=None)[source]¶
Bases:
PyQt5.QtWidgets.QFrame
- colorChanged¶
- class magicclass.widgets.color.QDoubleSlider(parent=None, decimals: int = 3)[source]¶
Bases:
PyQt5.QtWidgets.QSlider
- changed¶
magicclass.widgets.containers module¶
magicclass.widgets.logger module¶
- class magicclass.widgets.logger.Logger[source]¶
Bases:
magicgui.widgets._bases.widget.Widget
,logging.Handler
A widget for logging.
Examples
Create widget as other
magicgui
ormagicclass
widgets.logger = Logger(name="my logger") # magicgui way # magicclass way @magicclass class Main: logger = field(Logger, name="my logger") # This is OK @magicclass class Main: logger = Logger()
Print something in the widget
# print something in the widget. logger.print("text") # a context manager that change the destination of print function. with logger.set_stdout(): print("text") function_that_print_something() # permanently change the destination of print function sys.stdout = logger
Logging in the widget
with logger.set_logger(): function_that_log_something() logging.getLogger(__name__).addHandler(logger)
Inline plot in the widget
with logger.set_plt(): plt.plot(np.random.random(100))
- print_html(html: str, end='<br></br>')[source]¶
Print things in the end of the logger widget using HTML string.
- print_image(arr: str | Path | np.ndarray, vmin=None, vmax=None, cmap=None, norm=None, width=None, height=None) None [source]¶
Print an array as an image in the logger widget. Can be a path.
- print_rst(rst: str, end='\n')[source]¶
Print things in the end of the logger widget using rST string.
- print_table(table, header: bool = True, index: bool = True, precision: int | None = None)[source]¶
Print object as a table in the logger widget.
- Parameters
table (table-like object) -- Any object that can be passed to
pandas.DataFrame
can be used.header (bool, default is True) -- Whether to show the header row.
index (bool, default is True) -- Whether to show the index column.
precision (int, options) -- If given, float value will be rounded by this parameter.
- class magicclass.widgets.logger.Output[source]¶
Bases:
object
Logger output types.
- HTML = 1¶
- IMAGE = 2¶
- TEXT = 0¶
magicclass.widgets.misc module¶
- class magicclass.widgets.misc.AbstractRangeSlider(value=UNSET, min=0, max=1000, orientation: str = 'horizontal', nullable: bool = True, **kwargs)[source]¶
Bases:
magicgui.widgets._bases.value_widget.ValueWidget
,Generic
[magicclass.widgets.misc._V
]A slider widget that represent a range like (2, 5).
This class is a temporary one and may be substituted by magicgui widget soon. See https://github.com/napari/magicgui/pull/337.
- changed¶
Declares a signal emitter on a class.
This is class implements the [descriptor protocol](https://docs.python.org/3/howto/descriptor.html#descriptorhowto) and is designed to be used as a class attribute, with the supported signature types provided in the contructor:
```python from psygnal import Signal
- class MyEmitter:
changed = Signal(int)
- def receiver(arg: int):
print("new value:", arg)
emitter = MyEmitter() emitter.changed.connect(receiver) emitter.changed.emit(1) # prints 'new value: 1' ```
!!! note
in the example above, MyEmitter.changed is an instance of Signal, and emitter.changed is an instance of SignalInstance. See the documentation on [SignalInstance][psygnal.SignalInstance] for details on how to connect to and/or emit a signal on an instance of an object that has a Signal.
- Parameters
*types (Union[Type[Any], Signature]) -- A sequence of individual types, or a single [inspect.Signature][] object.
description (str) -- Optional descriptive text for the signal. (not used internally).
name (Optional[str]) -- 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 (bool) -- 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 (bool) -- 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 max: magicclass.widgets.misc._V¶
- property min: magicclass.widgets.misc._V¶
- property range: tuple[_V, _V]¶
- property value: tuple[_V, _V]¶
Return current value of the widget. This may be interpreted by backends.
- 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.
- property selected: str¶
Return selected string.
- property tab_size¶
- class magicclass.widgets.misc.FloatEdit(value=UNSET, **kwargs)[source]¶
Bases:
magicgui.widgets.LineEdit
- class magicclass.widgets.misc.HistoryFileEdit(mode: magicgui.types.FileDialogMode = FileDialogMode.EXISTING_FILE, filter=None, nullable=False, **kwargs)[source]¶
Bases:
magicgui.widgets.FileEdit
- class magicclass.widgets.misc.HistoryLineEdit(value=UNSET, **kwargs)[source]¶
Bases:
magicgui.widgets.LineEdit
- class magicclass.widgets.misc.IntEdit(value=UNSET, **kwargs)[source]¶
Bases:
magicgui.widgets.LineEdit
- class magicclass.widgets.misc.QFloatEdit(**kwargs)[source]¶
Bases:
magicgui.backends._qtpy.widgets.LineEdit
- class magicclass.widgets.misc.QHistoryLineEdit(**kwargs)[source]¶
Bases:
magicgui.backends._qtpy.widgets.QBaseStringWidget
- class magicclass.widgets.misc.QIntEdit(**kwargs)[source]¶
Bases:
magicgui.backends._qtpy.widgets.LineEdit
- class magicclass.widgets.misc.QRangeSlider(qwidg: type[PyQt5.QtWidgets.QWidget], parent: Optional[PyQt5.QtWidgets.QWidget] = None, **kwargs)[source]¶
Bases:
magicgui.backends._qtpy.widgets.QBaseWidget
- class magicclass.widgets.misc.SpreadSheet(read_only: bool = False)[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.
- property read_only¶
magicclass.widgets.plot module¶
- class magicclass.widgets.plot.Figure(nrows: int = 1, ncols: int = 1, figsize: tuple[float, float] = (4.0, 3.0), style=None, **kwargs)[source]¶
- class magicclass.widgets.plot.Figure(fig: magicclass.widgets.plot.Figure, **kwargs)
Bases:
magicclass.widgets.utils.FreeWidget
A matplotlib figure canvas.
- property ax: Axes¶
The first matplotlib axis.
- property axes: list[Axes]¶
List of matplotlib axes.
- property enabled: bool¶
toggle interactivity of the figure canvas.
- property interactive: bool¶
toggle interactivity of the figure canvas.
- property mouse_click_callbacks: list[Callable]¶
- class magicclass.widgets.plot.SeabornFigure(nrows: int = 1, ncols: int = 1, figsize: tuple[float, float] = (4.0, 3.0), style=None, **kwargs)[source]¶
Bases:
magicclass.widgets.plot.Figure
A matplotlib figure canvas implemented with seaborn plot functions.
Not all the seaborn plot functions are supported since some of them are figure-level functions and incompatible with specifying axes.
magicclass.widgets.separator module¶
- class magicclass.widgets.separator.Separator(orientation: str = 'horizontal', title: 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¶
Declares a signal emitter on a class.
This is class implements the [descriptor protocol](https://docs.python.org/3/howto/descriptor.html#descriptorhowto) and is designed to be used as a class attribute, with the supported signature types provided in the contructor:
```python from psygnal import Signal
- class MyEmitter:
changed = Signal(int)
- def receiver(arg: int):
print("new value:", arg)
emitter = MyEmitter() emitter.changed.connect(receiver) emitter.changed.emit(1) # prints 'new value: 1' ```
!!! note
in the example above, MyEmitter.changed is an instance of Signal, and emitter.changed is an instance of SignalInstance. See the documentation on [SignalInstance][psygnal.SignalInstance] for details on how to connect to and/or emit a signal on an instance of an object that has a Signal.
- Parameters
*types (Union[Type[Any], Signature]) -- A sequence of individual types, or a single [inspect.Signature][] object.
description (str) -- Optional descriptive text for the signal. (not used internally).
name (Optional[str]) -- 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 (bool) -- 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 (bool) -- 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¶
The button text.
- property title: str¶
The title string.
magicclass.widgets.sequence module¶
- class magicclass.widgets.sequence.ListDataView(obj: magicgui.widgets.ListEdit)[source]¶
Bases:
object
Data view of ListEdit.
magicclass.widgets.utils module¶
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: bool = False, parent: Any = None, backend_kwargs={}, layout: str = 'vertical', scrollable: bool = False, widgets: Sequence[Widget] = (), labels=True)¶
Bases:
magicgui.widgets._bases.container_widget.ContainerWidget
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
.enabled (bool) -- Whether the widget is enabled, by default
True
.gui_only (bool) -- If
True
, widget is excluded from any function signature representation. by defaultFalse
. (This will likely be deprecated.)parent (Widget) -- Optional parent widget of this widget. CAREFUL: if a parent is set, and subsequently deleted, this widget will likely be deleted as well (depending on the backend), and will no longer be usable.
backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.
layout (str) -- The layout for the container. must be one of
{'horizontal', 'vertical'}
. by default "vertical"scrollable (bool) -- Whether to enable scroll bars or not. If enabled, scroll bars will only appear along the layout direction, not in both directions.
widgets (Sequence[Widget]) -- A sequence of widgets with which to intialize the container, by default
None
.labels (bool) -- Whether each widget should be shown with a corresponding Label widget to the left, by default
True
. Note: the text for each widget defaults towidget.name
, but can be overriden by settingwidget.label
.
- 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: bool = False, parent: Any = None, backend_kwargs={}, layout: str = 'vertical', scrollable: bool = False, widgets: Sequence[Widget] = (), labels=True)¶
Bases:
magicgui.widgets._bases.container_widget.ContainerWidget
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
.enabled (bool) -- Whether the widget is enabled, by default
True
.gui_only (bool) -- If
True
, widget is excluded from any function signature representation. by defaultFalse
. (This will likely be deprecated.)parent (Widget) -- Optional parent widget of this widget. CAREFUL: if a parent is set, and subsequently deleted, this widget will likely be deleted as well (depending on the backend), and will no longer be usable.
backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.
layout (str) -- The layout for the container. must be one of
{'horizontal', 'vertical'}
. by default "vertical"scrollable (bool) -- Whether to enable scroll bars or not. If enabled, scroll bars will only appear along the layout direction, not in both directions.
widgets (Sequence[Widget]) -- A sequence of widgets with which to intialize the container, by default
None
.labels (bool) -- Whether each widget should be shown with a corresponding Label widget to the left, by default
True
. Note: the text for each widget defaults towidget.name
, but can be overriden by settingwidget.label
.
- 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: bool = False, parent: Any = None, 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
.enabled (bool) -- Whether the widget is enabled, by default
True
.gui_only (bool) -- If
True
, widget is excluded from any function signature representation. by defaultFalse
. (This will likely be deprecated.)parent (Widget) -- Optional parent widget of this widget. CAREFUL: if a parent is set, and subsequently deleted, this widget will likely be deleted as well (depending on the backend), and will no longer be usable.
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 casevalue(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: bool = False, parent: Any = None, 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
.enabled (bool) -- Whether the widget is enabled, by default
True
.gui_only (bool) -- If
True
, widget is excluded from any function signature representation. by defaultFalse
. (This will likely be deprecated.)parent (Widget) -- Optional parent widget of this widget. CAREFUL: if a parent is set, and subsequently deleted, this widget will likely be deleted as well (depending on the backend), and will no longer be usable.
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 casevalue(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.
- property selected: str¶
Return selected string.
- property tab_size¶
- class magicclass.widgets.DictWidget(value=None, **kwargs)[source]¶
Bases:
magicclass.widgets.pywidgets.object.BaseWidget
,MutableMapping
- items() magicclass.widgets.pywidgets.dict.DictItemView [source]¶
Return the view of dictionary keys and values as strings and Python objects.
- property value: dict[str, 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: bool = False, parent: Any = None, backend_kwargs={}, layout: str = 'vertical', scrollable: bool = False, widgets: Sequence[Widget] = (), labels=True)¶
Bases:
magicgui.widgets._bases.container_widget.ContainerWidget
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
.enabled (bool) -- Whether the widget is enabled, by default
True
.gui_only (bool) -- If
True
, widget is excluded from any function signature representation. by defaultFalse
. (This will likely be deprecated.)parent (Widget) -- Optional parent widget of this widget. CAREFUL: if a parent is set, and subsequently deleted, this widget will likely be deleted as well (depending on the backend), and will no longer be usable.
backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.
layout (str) -- The layout for the container. must be one of
{'horizontal', 'vertical'}
. by default "vertical"scrollable (bool) -- Whether to enable scroll bars or not. If enabled, scroll bars will only appear along the layout direction, not in both directions.
widgets (Sequence[Widget]) -- A sequence of widgets with which to intialize the container, by default
None
.labels (bool) -- Whether each widget should be shown with a corresponding Label widget to the left, by default
True
. Note: the text for each widget defaults towidget.name
, but can be overriden by settingwidget.label
.
- class magicclass.widgets.Figure(nrows: int = 1, ncols: int = 1, figsize: tuple[float, float] = (4.0, 3.0), style=None, **kwargs)[source]¶
- class magicclass.widgets.Figure(fig: magicclass.widgets.plot.Figure, **kwargs)
Bases:
magicclass.widgets.utils.FreeWidget
A matplotlib figure canvas.
- property ax: Axes¶
The first matplotlib axis.
- property axes: list[Axes]¶
List of matplotlib axes.
- property enabled: bool¶
toggle interactivity of the figure canvas.
- property interactive: bool¶
toggle interactivity of the figure canvas.
- property mouse_click_callbacks: list[Callable]¶
- class magicclass.widgets.FloatRangeSlider(name: str = '', annotation: Any = None, label: str = None, tooltip: str | None = None, visible: bool | None = None, enabled: bool = True, gui_only: bool = False, parent: Any = None, backend_kwargs={}, value: Any = UNSET, bind: Any = UNSET, nullable=False, min: Union[float, magicgui.widgets._bases.value_widget._Unset] = UNSET, max: Union[float, magicgui.widgets._bases.value_widget._Unset] = UNSET, step: Optional[Union[float, magicgui.widgets._bases.value_widget._Unset]] = UNSET, orientation: str = 'horizontal', readout: bool = True, tracking: bool = True)¶
Bases:
magicgui.widgets._bases.slider_widget.MultiValuedSliderWidget
A slider widget to adjust a range defined by two float values within a range.
- 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
.enabled (bool) -- Whether the widget is enabled, by default
True
.gui_only (bool) -- If
True
, widget is excluded from any function signature representation. by defaultFalse
. (This will likely be deprecated.)parent (Widget) -- Optional parent widget of this widget. CAREFUL: if a parent is set, and subsequently deleted, this widget will likely be deleted as well (depending on the backend), and will no longer be usable.
backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.
value (Any) -- 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 casevalue(self)
will be returned (i.e. your callback must accept a single parameter, which is this widget instance.).min (float) -- The minimum allowable value, by default 0 (or value if value is less than 0)
max (float) -- The maximum allowable value, by default 999 (or value if value is greater than 999)
step (float) -- The step size for incrementing the value, by default adaptive step is used
orientation (str, {'horizontal', 'vertical'}) -- The orientation for the slider, by default "horizontal"
readout (bool) -- Whether to show the editable spinbox next to the slider
tracking (bool) -- If tracking is enabled (the default), the slider emits the changed signal while the slider is being dragged. If tracking is disabled, the slider emits the changed signal only after the user releases the slider.
- 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: bool = False, parent: Any = None, backend_kwargs={}, layout: str = 'vertical', scrollable: bool = False, widgets: Sequence[Widget] = (), labels=True)¶
Bases:
magicgui.widgets._bases.container_widget.ContainerWidget
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
.enabled (bool) -- Whether the widget is enabled, by default
True
.gui_only (bool) -- If
True
, widget is excluded from any function signature representation. by defaultFalse
. (This will likely be deprecated.)parent (Widget) -- Optional parent widget of this widget. CAREFUL: if a parent is set, and subsequently deleted, this widget will likely be deleted as well (depending on the backend), and will no longer be usable.
backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.
layout (str) -- The layout for the container. must be one of
{'horizontal', 'vertical'}
. by default "vertical"scrollable (bool) -- Whether to enable scroll bars or not. If enabled, scroll bars will only appear along the layout direction, not in both directions.
widgets (Sequence[Widget]) -- A sequence of widgets with which to intialize the container, by default
None
.labels (bool) -- Whether each widget should be shown with a corresponding Label widget to the left, by default
True
. Note: the text for each widget defaults towidget.name
, but can be overriden by settingwidget.label
.
- class magicclass.widgets.FreeWidget(layout='vertical', **kwargs)[source]¶
Bases:
magicgui.widgets._bases.widget.Widget
A Widget class with any QWidget as a child.
- 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: bool = False, parent: Any = None, backend_kwargs={}, layout: str = 'vertical', scrollable: bool = False, widgets: Sequence[Widget] = (), labels=True)¶
Bases:
magicgui.widgets._bases.container_widget.ContainerWidget
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
.enabled (bool) -- Whether the widget is enabled, by default
True
.gui_only (bool) -- If
True
, widget is excluded from any function signature representation. by defaultFalse
. (This will likely be deprecated.)parent (Widget) -- Optional parent widget of this widget. CAREFUL: if a parent is set, and subsequently deleted, this widget will likely be deleted as well (depending on the backend), and will no longer be usable.
backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.
layout (str) -- The layout for the container. must be one of
{'horizontal', 'vertical'}
. by default "vertical"scrollable (bool) -- Whether to enable scroll bars or not. If enabled, scroll bars will only appear along the layout direction, not in both directions.
widgets (Sequence[Widget]) -- A sequence of widgets with which to intialize the container, by default
None
.labels (bool) -- Whether each widget should be shown with a corresponding Label widget to the left, by default
True
. Note: the text for each widget defaults towidget.name
, but can be overriden by settingwidget.label
.
- 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: bool = False, parent: Any = None, backend_kwargs={}, layout: str = 'vertical', scrollable: bool = False, widgets: Sequence[Widget] = (), labels=True)¶
Bases:
magicgui.widgets._bases.container_widget.ContainerWidget
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
.enabled (bool) -- Whether the widget is enabled, by default
True
.gui_only (bool) -- If
True
, widget is excluded from any function signature representation. by defaultFalse
. (This will likely be deprecated.)parent (Widget) -- Optional parent widget of this widget. CAREFUL: if a parent is set, and subsequently deleted, this widget will likely be deleted as well (depending on the backend), and will no longer be usable.
backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.
layout (str) -- The layout for the container. must be one of
{'horizontal', 'vertical'}
. by default "vertical"scrollable (bool) -- Whether to enable scroll bars or not. If enabled, scroll bars will only appear along the layout direction, not in both directions.
widgets (Sequence[Widget]) -- A sequence of widgets with which to intialize the container, by default
None
.labels (bool) -- Whether each widget should be shown with a corresponding Label widget to the left, by default
True
. Note: the text for each widget defaults towidget.name
, but can be overriden by settingwidget.label
.
- property collapsed: bool¶
- class magicclass.widgets.HistoryFileEdit(mode: magicgui.types.FileDialogMode = FileDialogMode.EXISTING_FILE, filter=None, nullable=False, **kwargs)[source]¶
Bases:
magicgui.widgets.FileEdit
- class magicclass.widgets.HistoryLineEdit(value=UNSET, **kwargs)[source]¶
Bases:
magicgui.widgets.LineEdit
- 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: bool = False, parent: Any = None, backend_kwargs={}, layout: str = 'vertical', scrollable: bool = False, widgets: Sequence[Widget] = (), labels=True)¶
Bases:
magicgui.widgets._bases.container_widget.ContainerWidget
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
.enabled (bool) -- Whether the widget is enabled, by default
True
.gui_only (bool) -- If
True
, widget is excluded from any function signature representation. by defaultFalse
. (This will likely be deprecated.)parent (Widget) -- Optional parent widget of this widget. CAREFUL: if a parent is set, and subsequently deleted, this widget will likely be deleted as well (depending on the backend), and will no longer be usable.
backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.
layout (str) -- The layout for the container. must be one of
{'horizontal', 'vertical'}
. by default "vertical"scrollable (bool) -- Whether to enable scroll bars or not. If enabled, scroll bars will only appear along the layout direction, not in both directions.
widgets (Sequence[Widget]) -- A sequence of widgets with which to intialize the container, by default
None
.labels (bool) -- Whether each widget should be shown with a corresponding Label widget to the left, by default
True
. Note: the text for each widget defaults towidget.name
, but can be overriden by settingwidget.label
.
- 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: bool = False, parent: Any = None, backend_kwargs={}, layout: str = 'horizontal', scrollable: bool = False, widgets: Sequence[Widget] = (), labels: bool = False, value: Iterable[_V] | _Unset = UNSET, nullable: bool = False, options: WidgetOptions = None)¶
Bases:
magicgui.widgets.Container
- 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
.enabled (bool) -- Whether the widget is enabled, by default
True
.gui_only (bool) -- If
True
, widget is excluded from any function signature representation. by defaultFalse
. (This will likely be deprecated.)parent (Widget) -- Optional parent widget of this widget. CAREFUL: if a parent is set, and subsequently deleted, this widget will likely be deleted as well (depending on the backend), and will no longer be usable.
backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.
layout (str) -- The layout for the container. must be one of
{'horizontal', 'vertical'}
. by default "vertical"scrollable (bool) -- Whether to enable scroll bars or not. If enabled, scroll bars will only appear along the layout direction, not in both directions.
widgets (Sequence[Widget]) -- A sequence of widgets with which to intialize the container, by default
None
.labels (bool) -- Whether each widget should be shown with a corresponding Label widget to the left, by default
True
. Note: the text for each widget defaults towidget.name
, but can be overriden by settingwidget.label
.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
.enabled -- Whether the widget is enabled, by default
True
.gui_only -- If
True
, widget is excluded from any function signature representation. by defaultFalse
. (This will likely be deprecated.)parent -- Optional parent widget of this widget. CAREFUL: if a parent is set, and subsequently deleted, this widget will likely be deleted as well (depending on the backend), and will no longer be usable.
backend_kwargs -- keyword argument to pass to the backend widget constructor.
layout -- The layout for the container. must be one of
{'horizontal', 'vertical'}
. by default "vertical"scrollable -- Whether to enable scroll bars or not. If enabled, scroll bars will only appear along the layout direction, not in both directions.
widgets -- A sequence of widgets with which to intialize the container, by default
None
.labels -- Whether each widget should be shown with a corresponding Label widget to the left, by default
True
. Note: the text for each widget defaults towidget.name
, but can be overriden by settingwidget.label
.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 buttons_visible: bool¶
Toggle visibility of +/- buttons.
- 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
- 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.
- property value: list[Any]¶
Get all the contents as a Python list.
- Returns
Contents of the list widget.
- Return type
list
- class magicclass.widgets.Logger[source]¶
Bases:
magicgui.widgets._bases.widget.Widget
,logging.Handler
A widget for logging.
Examples
Create widget as other
magicgui
ormagicclass
widgets.logger = Logger(name="my logger") # magicgui way # magicclass way @magicclass class Main: logger = field(Logger, name="my logger") # This is OK @magicclass class Main: logger = Logger()
Print something in the widget
# print something in the widget. logger.print("text") # a context manager that change the destination of print function. with logger.set_stdout(): print("text") function_that_print_something() # permanently change the destination of print function sys.stdout = logger
Logging in the widget
with logger.set_logger(): function_that_log_something() logging.getLogger(__name__).addHandler(logger)
Inline plot in the widget
with logger.set_plt(): plt.plot(np.random.random(100))
- print_html(html: str, end='<br></br>')[source]¶
Print things in the end of the logger widget using HTML string.
- print_image(arr: str | Path | np.ndarray, vmin=None, vmax=None, cmap=None, norm=None, width=None, height=None) None [source]¶
Print an array as an image in the logger widget. Can be a path.
- print_rst(rst: str, end='\n')[source]¶
Print things in the end of the logger widget using rST string.
- print_table(table, header: bool = True, index: bool = True, precision: int | None = None)[source]¶
Print object as a table in the logger widget.
- Parameters
table (table-like object) -- Any object that can be passed to
pandas.DataFrame
can be used.header (bool, default is True) -- Whether to show the header row.
index (bool, default is True) -- Whether to show the index column.
precision (int, options) -- If given, float value will be rounded by this parameter.
- 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: bool = False, parent: Any = None, backend_kwargs={}, layout: str = 'vertical', scrollable: bool = False, widgets: Sequence[Widget] = (), labels=True, inner_widget: type[ValueWidget] | None = None, text: str | None = None, nullable: bool = True, value=UNSET, options: WidgetOptions | None = None)¶
Bases:
magicgui.widgets.Container
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
.enabled (bool) -- Whether the widget is enabled, by default
True
.gui_only (bool) -- If
True
, widget is excluded from any function signature representation. by defaultFalse
. (This will likely be deprecated.)parent (Widget) -- Optional parent widget of this widget. CAREFUL: if a parent is set, and subsequently deleted, this widget will likely be deleted as well (depending on the backend), and will no longer be usable.
backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.
layout (str) -- The layout for the container. must be one of
{'horizontal', 'vertical'}
. by default "vertical"scrollable (bool) -- Whether to enable scroll bars or not. If enabled, scroll bars will only appear along the layout direction, not in both directions.
widgets (Sequence[Widget]) -- A sequence of widgets with which to intialize the container, by default
None
.labels (bool) -- Whether each widget should be shown with a corresponding Label widget to the left, by default
True
. Note: the text for each widget defaults towidget.name
, but can be overriden by settingwidget.label
.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
.enabled -- Whether the widget is enabled, by default
True
.gui_only -- If
True
, widget is excluded from any function signature representation. by defaultFalse
. (This will likely be deprecated.)parent -- Optional parent widget of this widget. CAREFUL: if a parent is set, and subsequently deleted, this widget will likely be deleted as well (depending on the backend), and will no longer be usable.
backend_kwargs -- keyword argument to pass to the backend widget constructor.
layout -- The layout for the container. must be one of
{'horizontal', 'vertical'}
. by default "vertical"scrollable -- Whether to enable scroll bars or not. If enabled, scroll bars will only appear along the layout direction, not in both directions.
widgets -- A sequence of widgets with which to intialize the container, by default
None
.labels -- Whether each widget should be shown with a corresponding Label widget to the left, by default
True
. Note: the text for each widget defaults towidget.name
, but can be overriden by settingwidget.label
.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.RangeSlider(name: str = '', annotation: Any = None, label: str = None, tooltip: str | None = None, visible: bool | None = None, enabled: bool = True, gui_only: bool = False, parent: Any = None, backend_kwargs={}, value: Any = UNSET, bind: Any = UNSET, nullable=False, min: Union[float, magicgui.widgets._bases.value_widget._Unset] = UNSET, max: Union[float, magicgui.widgets._bases.value_widget._Unset] = UNSET, step: Optional[Union[float, magicgui.widgets._bases.value_widget._Unset]] = UNSET, orientation: str = 'horizontal', readout: bool = True, tracking: bool = True)¶
Bases:
magicgui.widgets._bases.slider_widget.MultiValuedSliderWidget
A slider widget to adjust a range between two integer values within a range.
- 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
.enabled (bool) -- Whether the widget is enabled, by default
True
.gui_only (bool) -- If
True
, widget is excluded from any function signature representation. by defaultFalse
. (This will likely be deprecated.)parent (Widget) -- Optional parent widget of this widget. CAREFUL: if a parent is set, and subsequently deleted, this widget will likely be deleted as well (depending on the backend), and will no longer be usable.
backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.
value (Any) -- 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 casevalue(self)
will be returned (i.e. your callback must accept a single parameter, which is this widget instance.).min (float) -- The minimum allowable value, by default 0 (or value if value is less than 0)
max (float) -- The maximum allowable value, by default 999 (or value if value is greater than 999)
step (float) -- The step size for incrementing the value, by default adaptive step is used
orientation (str, {'horizontal', 'vertical'}) -- The orientation for the slider, by default "horizontal"
readout (bool) -- Whether to show the editable spinbox next to the slider
tracking (bool) -- If tracking is enabled (the default), the slider emits the changed signal while the slider is being dragged. If tracking is disabled, the slider emits the changed signal only after the user releases the slider.
- 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: bool = False, parent: Any = None, backend_kwargs={}, layout: str = 'vertical', scrollable: bool = False, widgets: Sequence[Widget] = (), labels=True)¶
Bases:
magicgui.widgets._bases.container_widget.ContainerWidget
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
.enabled (bool) -- Whether the widget is enabled, by default
True
.gui_only (bool) -- If
True
, widget is excluded from any function signature representation. by defaultFalse
. (This will likely be deprecated.)parent (Widget) -- Optional parent widget of this widget. CAREFUL: if a parent is set, and subsequently deleted, this widget will likely be deleted as well (depending on the backend), and will no longer be usable.
backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.
layout (str) -- The layout for the container. must be one of
{'horizontal', 'vertical'}
. by default "vertical"scrollable (bool) -- Whether to enable scroll bars or not. If enabled, scroll bars will only appear along the layout direction, not in both directions.
widgets (Sequence[Widget]) -- A sequence of widgets with which to intialize the container, by default
None
.labels (bool) -- Whether each widget should be shown with a corresponding Label widget to the left, by default
True
. Note: the text for each widget defaults towidget.name
, but can be overriden by settingwidget.label
.
- class magicclass.widgets.SeabornFigure(nrows: int = 1, ncols: int = 1, figsize: tuple[float, float] = (4.0, 3.0), style=None, **kwargs)[source]¶
Bases:
magicclass.widgets.plot.Figure
A matplotlib figure canvas implemented with seaborn plot functions.
Not all the seaborn plot functions are supported since some of them are figure-level functions and incompatible with specifying axes.
- class magicclass.widgets.Separator(orientation: str = 'horizontal', title: 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¶
Declares a signal emitter on a class.
This is class implements the [descriptor protocol](https://docs.python.org/3/howto/descriptor.html#descriptorhowto) and is designed to be used as a class attribute, with the supported signature types provided in the contructor:
```python from psygnal import Signal
- class MyEmitter:
changed = Signal(int)
- def receiver(arg: int):
print("new value:", arg)
emitter = MyEmitter() emitter.changed.connect(receiver) emitter.changed.emit(1) # prints 'new value: 1' ```
!!! note
in the example above, MyEmitter.changed is an instance of Signal, and emitter.changed is an instance of SignalInstance. See the documentation on [SignalInstance][psygnal.SignalInstance] for details on how to connect to and/or emit a signal on an instance of an object that has a Signal.
- Parameters
*types (Union[Type[Any], Signature]) -- A sequence of individual types, or a single [inspect.Signature][] object.
description (str) -- Optional descriptive text for the signal. (not used internally).
name (Optional[str]) -- 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 (bool) -- 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 (bool) -- 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¶
The button text.
- central_widget: QWidget | None¶
- name: str¶
- property title: str¶
The title string.
- 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: bool = False, parent: Any = None, backend_kwargs={}, layout: str = 'vertical', scrollable: bool = False, widgets: Sequence[Widget] = (), labels=True)¶
Bases:
magicgui.widgets._bases.container_widget.ContainerWidget
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
.enabled (bool) -- Whether the widget is enabled, by default
True
.gui_only (bool) -- If
True
, widget is excluded from any function signature representation. by defaultFalse
. (This will likely be deprecated.)parent (Widget) -- Optional parent widget of this widget. CAREFUL: if a parent is set, and subsequently deleted, this widget will likely be deleted as well (depending on the backend), and will no longer be usable.
backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.
layout (str) -- The layout for the container. must be one of
{'horizontal', 'vertical'}
. by default "vertical"scrollable (bool) -- Whether to enable scroll bars or not. If enabled, scroll bars will only appear along the layout direction, not in both directions.
widgets (Sequence[Widget]) -- A sequence of widgets with which to intialize the container, by default
None
.labels (bool) -- Whether each widget should be shown with a corresponding Label widget to the left, by default
True
. Note: the text for each widget defaults towidget.name
, but can be overriden by settingwidget.label
.
- class magicclass.widgets.SpreadSheet(read_only: bool = False)[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.
- property read_only¶
- 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: bool = False, parent: Any = None, backend_kwargs={}, layout: str = 'vertical', scrollable: bool = False, widgets: Sequence[Widget] = (), labels=True)¶
Bases:
magicgui.widgets._bases.container_widget.ContainerWidget
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
.enabled (bool) -- Whether the widget is enabled, by default
True
.gui_only (bool) -- If
True
, widget is excluded from any function signature representation. by defaultFalse
. (This will likely be deprecated.)parent (Widget) -- Optional parent widget of this widget. CAREFUL: if a parent is set, and subsequently deleted, this widget will likely be deleted as well (depending on the backend), and will no longer be usable.
backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.
layout (str) -- The layout for the container. must be one of
{'horizontal', 'vertical'}
. by default "vertical"scrollable (bool) -- Whether to enable scroll bars or not. If enabled, scroll bars will only appear along the layout direction, not in both directions.
widgets (Sequence[Widget]) -- A sequence of widgets with which to intialize the container, by default
None
.labels (bool) -- Whether each widget should be shown with a corresponding Label widget to the left, by default
True
. Note: the text for each widget defaults towidget.name
, but can be overriden by settingwidget.label
.
- 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: bool = False, parent: Any = None, backend_kwargs={}, layout: str = 'vertical', scrollable: bool = False, widgets: Sequence[Widget] = (), labels=True)¶
Bases:
magicgui.widgets._bases.container_widget.ContainerWidget
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
.enabled (bool) -- Whether the widget is enabled, by default
True
.gui_only (bool) -- If
True
, widget is excluded from any function signature representation. by defaultFalse
. (This will likely be deprecated.)parent (Widget) -- Optional parent widget of this widget. CAREFUL: if a parent is set, and subsequently deleted, this widget will likely be deleted as well (depending on the backend), and will no longer be usable.
backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.
layout (str) -- The layout for the container. must be one of
{'horizontal', 'vertical'}
. by default "vertical"scrollable (bool) -- Whether to enable scroll bars or not. If enabled, scroll bars will only appear along the layout direction, not in both directions.
widgets (Sequence[Widget]) -- A sequence of widgets with which to intialize the container, by default
None
.labels (bool) -- Whether each widget should be shown with a corresponding Label widget to the left, by default
True
. Note: the text for each widget defaults towidget.name
, but can be overriden by settingwidget.label
.
- 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: bool = False, parent: Any = None, backend_kwargs={}, layout: str = 'vertical', scrollable: bool = False, widgets: Sequence[Widget] = (), labels=True)¶
Bases:
magicgui.widgets._bases.container_widget.ContainerWidget
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
.enabled (bool) -- Whether the widget is enabled, by default
True
.gui_only (bool) -- If
True
, widget is excluded from any function signature representation. by defaultFalse
. (This will likely be deprecated.)parent (Widget) -- Optional parent widget of this widget. CAREFUL: if a parent is set, and subsequently deleted, this widget will likely be deleted as well (depending on the backend), and will no longer be usable.
backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.
layout (str) -- The layout for the container. must be one of
{'horizontal', 'vertical'}
. by default "vertical"scrollable (bool) -- Whether to enable scroll bars or not. If enabled, scroll bars will only appear along the layout direction, not in both directions.
widgets (Sequence[Widget]) -- A sequence of widgets with which to intialize the container, by default
None
.labels (bool) -- Whether each widget should be shown with a corresponding Label widget to the left, by default
True
. Note: the text for each widget defaults towidget.name
, but can be overriden by settingwidget.label
.
- 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: bool = False, parent: Any = None, backend_kwargs={}, layout: str = 'vertical', scrollable: bool = False, widgets: Sequence[Widget] = (), labels=True)¶
Bases:
magicgui.widgets._bases.container_widget.ContainerWidget
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
.enabled (bool) -- Whether the widget is enabled, by default
True
.gui_only (bool) -- If
True
, widget is excluded from any function signature representation. by defaultFalse
. (This will likely be deprecated.)parent (Widget) -- Optional parent widget of this widget. CAREFUL: if a parent is set, and subsequently deleted, this widget will likely be deleted as well (depending on the backend), and will no longer be usable.
backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.
layout (str) -- The layout for the container. must be one of
{'horizontal', 'vertical'}
. by default "vertical"scrollable (bool) -- Whether to enable scroll bars or not. If enabled, scroll bars will only appear along the layout direction, not in both directions.
widgets (Sequence[Widget]) -- A sequence of widgets with which to intialize the container, by default
None
.labels (bool) -- Whether each widget should be shown with a corresponding Label widget to the left, by default
True
. Note: the text for each widget defaults towidget.name
, but can be overriden by settingwidget.label
.
- 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: bool = False, parent: Any = None, backend_kwargs={}, layout: str = 'horizontal', scrollable: bool = False, widgets: Sequence[Widget] = (), labels=True, value: Iterable[_V] | _Unset = UNSET, nullable: bool = False, options: WidgetOptions = None)¶
Bases:
magicgui.widgets.Container
- 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
.enabled (bool) -- Whether the widget is enabled, by default
True
.gui_only (bool) -- If
True
, widget is excluded from any function signature representation. by defaultFalse
. (This will likely be deprecated.)parent (Widget) -- Optional parent widget of this widget. CAREFUL: if a parent is set, and subsequently deleted, this widget will likely be deleted as well (depending on the backend), and will no longer be usable.
backend_kwargs (dict) -- keyword argument to pass to the backend widget constructor.
layout (str) -- The layout for the container. must be one of
{'horizontal', 'vertical'}
. by default "vertical"scrollable (bool) -- Whether to enable scroll bars or not. If enabled, scroll bars will only appear along the layout direction, not in both directions.
widgets (Sequence[Widget]) -- A sequence of widgets with which to intialize the container, by default
None
.labels (bool) -- Whether each widget should be shown with a corresponding Label widget to the left, by default
True
. Note: the text for each widget defaults towidget.name
, but can be overriden by settingwidget.label
.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
.enabled -- Whether the widget is enabled, by default
True
.gui_only -- If
True
, widget is excluded from any function signature representation. by defaultFalse
. (This will likely be deprecated.)parent -- Optional parent widget of this widget. CAREFUL: if a parent is set, and subsequently deleted, this widget will likely be deleted as well (depending on the backend), and will no longer be usable.
backend_kwargs -- keyword argument to pass to the backend widget constructor.
layout -- The layout for the container. must be one of
{'horizontal', 'vertical'}
. by default "vertical"scrollable -- Whether to enable scroll bars or not. If enabled, scroll bars will only appear along the layout direction, not in both directions.
widgets -- A sequence of widgets with which to intialize the container, by default
None
.labels -- Whether each widget should be shown with a corresponding Label widget to the left, by default
True
. Note: the text for each widget defaults towidget.name
, but can be overriden by settingwidget.label
.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.