Skip to content

textual_fspicker.file_open

Provides a file opening dialog.

FileOpen

FileOpen(
    location=".",
    title="Open",
    *,
    open_button="",
    cancel_button="",
    filters=None,
    must_exist=True,
    default_file=None,
)

Bases: BaseFileDialog

A file opening dialog.

Parameters:

Name Type Description Default

location

str | Path

Optional starting location.

'.'

title

str

Optional title.

'Open'

open_button

ButtonLabel

The label for the open button.

''

cancel_button

ButtonLabel

The label for the cancel button.

''

filters

Filters | None

Optional filters to show in the dialog.

None

must_exist

bool

Flag to say if the file must exist.

True

default_file

str | Path | None

The default filename to place in the input.

None
Notes

open_button and cancel_button can either be strings that set the button label, or they can be functions that take the default button label as a parameter and return the label to use.

ERROR_A_FILE_MUST_EXIST class-attribute instance-attribute

ERROR_A_FILE_MUST_EXIST = 'The file must exist'

An error to show a user when a file must exist.