Skip to content

Note

Click here to download the full example code

File dialog widget#

A dialog to select multiple files.

files dialog

Out:

<FunctionGui filespicker(filenames: collections.abc.Sequence[pathlib._local.Path] = ()) -> collections.abc.Sequence[pathlib._local.Path]>


from collections.abc import Sequence
from pathlib import Path

from magicgui import magicgui


# Sequence of paths
# We change the label using "label" for added clarity
# the filter argument restricts file types
@magicgui(filenames={"label": "Choose Tiff files:", "filter": "*.tif"})
def filespicker(filenames: Sequence[Path]) -> Sequence[Path]:
    """Take a filename and do something with it."""
    print("The filenames are:", filenames)
    return filenames


filespicker.filenames.changed.connect(print)
filespicker.show(run=True)

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

Download Python source code: files_dialog.py

Download Jupyter notebook: files_dialog.ipynb

Gallery generated by mkdocs-gallery