Note
Click here to download the full example code
Optional user choice#
Optional user input using a dropdown selection widget.
Out:
<FunctionGui f(path: str = None)>
from typing import Optional
from magicgui import magicgui
# Using optional will add a '----' to the combobox, which returns "None"
@magicgui(path={"choices": ["a", "b"]})
def f(path: Optional[str] = None):
"""Öptional user input function."""
print(path, type(path))
f.show(run=True)
Total running time of the script: ( 0 minutes 0.038 seconds)
Download Python source code: optional.py