Skip to content

Note

Click here to download the full example code

Directory dialog widget#

A dialog to select a directory.

directory dialog

Out:

<FunctionGui directorypicker(directory=PosixPath('~'))>


from pathlib import Path

from magicgui import magicgui


# Select a directory, instead of file(s)
@magicgui(directory={"mode": "d", "label": "Choose a directory"})
def directorypicker(directory=Path("~")):
    """Take a directory name and do something with it."""
    print("The directory name is:", directory)
    return directory


directorypicker.directory.changed.connect(print)
directorypicker.show(run=True)

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

Download Python source code: directory_dialog.py

Download Jupyter notebook: directory_dialog.ipynb

Gallery generated by mkdocs-gallery