FunctionGui¶
- class magicgui.widgets.FunctionGui(function, call_button=None, layout='vertical', scrollable=False, labels=True, tooltips=True, app=None, visible=None, auto_call=False, result_widget=False, param_options=None, name=None, persist=False, **kwargs)[source]¶
Bases:
magicgui.widgets.Container
,Generic
[magicgui.widgets._function_gui._R
]Wrapper for a container of widgets representing a callable object.
- Parameters
function (Callable) – A callable to turn into a GUI
call_button (bool, str, or None, optional) – If True, create an additional button that calls the original function when clicked. If a
str
, set the button text. by default False when auto_call is True, and True otherwise. The button can be accessed from the.call_button
property.layout (str, optional) – The type of layout to use. Must be one of {‘horizontal’, ‘vertical’}. by default “horizontal”.
scrollable (bool, optional) – Whether to enable scroll bars or not. If enabled, scroll bars will only appear along the layout direction, not in both directions.
labels (bool, optional) – Whether labels are shown in the widget. by default True
tooltips (bool, optional) – Whether tooltips are shown when hovering over widgets. by default True
app (magicgui.Application or str, optional) – A backend to use, by default
None
(use the default backend.)visible (bool, optional) – Whether to immediately show the widget. If
False
, widget is explicitly hidden. IfNone
, widget is not shown, but will be shown if a parent container is shown, by default None.auto_call (bool, optional) – If True, changing any parameter in either the GUI or the widget attributes will call the original function with the current settings. by default False
result_widget (bool, optional) – Whether to display a LineEdit widget the output of the function when called, by default False
param_options (dict, optional) – A dict of name: widget_options dict for each parameter in the function. Will be passed to magic_signature by default
None
name (str, optional) – A name to assign to the Container widget, by default function.__name__
persist (bool, optional) – If True, when parameter values change in the widget, they will be stored to disk (in ~/.config/magicgui/cache) and restored when the widget is loaded again with
persist = True
. By default, False.
- Raises
TypeError – If unexpected keyword arguments are provided
Methods
append
(value)S.append(value) -- append value to the end of the sequence
asdict
()Return state of widget as dict.
clear
()close
()Close widget.
copy
()Return a copy of this FunctionGui.
count
(value)extend
(values)S.extend(iterable) -- extend sequence by appending elements from the iterable
from_callable
(obj[, gui_options])Create a Container widget from a callable object.
from_signature
(sig, **kwargs)Create a Container widget from an inspect.Signature object.
hide
()Hide widget.
index
(value[, start, stop])Return index of a specific widget instance (or widget name).
insert
(key, widget)Insert widget at
key
.pop
([index])Raise IndexError if list is empty or index is out of range.
remove
(value)Remove a widget instance (may also be string name of widget).
render
()Return an RGBA (MxNx4) numpy array bitmap of the rendered widget.
reset_call_count
()Reset the call count to 0.
reset_choices
(*_)Reset choices for all Categorical subWidgets to the default state.
reverse
()S.reverse() -- reverse IN PLACE
show
([run])Show widget.
shown
()Context manager to show the widget.
update
([mapping])Update the parameters in the widget from a mapping, iterable, or kwargs.
Attributes
NO_VALUE
annotation
Return type annotation for the parameter represented by the widget.
call_button
Return the call button.
call_count
Return the number of times the function has been called.
called
Declares a signal emitter on a class.
changed
Declares a signal emitter on a class.
enabled
Whether widget is enabled (editable).
height
Return the current height of the widget.
label
Return a label to use for this widget when present in Containers.
label_changed
Declares a signal emitter on a class.
labels
Whether widgets are presented with labels.
layout
Return the layout of the widget.
margins
Return margin between the content and edges of the container.
max_height
Get the maximum height of the widget.
max_width
Get the maximum width of the widget.
min_height
Get the minimum height of the widget.
min_width
Get the minimum width of the widget.
native
Return native backend widget.
options
Return options currently being used in this widget.
orientation
Orientation of the widget.
param_kind
Return
inspect.Parameter.kind
represented by this widget.parent
Return the parent widget.
parent_changed
Declares a signal emitter on a class.
result_name
Return a name that can be used for the result of this magicfunction.
return_annotation
Return annotation to use when converting to
inspect.Signature
.root_native_widget
Return the root native backend widget.
tooltip
Get the tooltip for this widget.
visible
Return whether widget is visible.
widget_type
Return type of widget.
width
Return the current width of the widget.