Skip to content

Note

Click here to download the full example code

Self reference magicgui widgets#

Widgets created with magicgui can reference themselves, and use the widget API.

self reference

Out:

<FunctionGui function(width=400, x: int = 50)>


from magicgui import magicgui


@magicgui(auto_call=True, width={"max": 800, "min": 100}, x={"widget_type": "Slider"})
def function(width=400, x: int = 50):
    """Example function."""
    # the widget can reference itself, and use the widget API
    function.x.width = width


function.show(run=True)

Total running time of the script: ( 0 minutes 0.037 seconds)

Download Python source code: self_reference.py

Download Jupyter notebook: self_reference.ipynb

Gallery generated by mkdocs-gallery