FileChooserRequest

class FileChooserRequest(**properties: Any)

Superclasses: Object

Constructors:

FileChooserRequest(**properties)

Methods

class FileChooserRequest
cancel() None

Ask WebKit to cancel the request.

It’s important to do this in case no selection has been made in the client, otherwise the request won’t be properly completed and the browser will keep the request pending forever, which might cause the browser to hang.

get_mime_types() list[str]

Get the list of MIME types the file chooser dialog should handle.

Get the list of MIME types the file chooser dialog should handle, in the format specified in RFC 2046 for “media types”. Its contents depend on the value of the ‘accept’ attribute for HTML input elements. This function should normally be called before presenting the file chooser dialog to the user, to decide whether to allow the user to select multiple files at once or only one.

get_mime_types_filter() FileFilter

Get the filter currently associated with the request.

Get the filter currently associated with the request, ready to be used by FileChooser. This function should normally be called before presenting the file chooser dialog to the user, to decide whether to apply a filter so the user would not be allowed to select files with other MIME types.

See get_mime_types() if you are interested in getting the list of accepted MIME types.

get_select_multiple() bool

Whether the file chooser should allow selecting multiple files.

Determine whether the file chooser associated to this FileChooserRequest should allow selecting multiple files, which depends on the HTML input element having a ‘multiple’ attribute defined.

get_selected_files() list[str]

Get the list of selected files associated to the request.

Get the list of selected files currently associated to the request. Initially, the return value of this method contains any files selected in previous file chooser requests for this HTML input element. Once webkit_file_chooser_request_select_files, the value will reflect whatever files are given.

This function should normally be called only before presenting the file chooser dialog to the user, to decide whether to perform some extra action, like pre-selecting the files from a previous request.

select_files(files: Sequence[str]) None

Ask WebKit to select local files for upload and complete the request.

Parameters:

files – a None-terminated array of strings, containing paths to local files.

Properties

class FileChooserRequest
props.filter: FileFilter

The filter currently associated with the request. See get_mime_types_filter() for more details.

props.mime_types: Sequence[str]

A None-terminated array of strings containing the list of MIME types the file chooser dialog should handle. See get_mime_types() for more details.

props.select_multiple: bool

Whether the file chooser should allow selecting multiple files. See get_select_multiple() for more details.

props.selected_files: Sequence[str]

A None-terminated array of strings containing the list of selected files associated to the current request. See get_selected_files() for more details.