FileDialog#
Added in version 4.10.
Superclasses: Object
A GtkFileDialog object collects the arguments that
are needed to present a file chooser dialog to the
user, such as a title for the dialog and whether it
should be modal.
The dialog is shown with open,
save, etc.
Constructors#
- class FileDialog
- classmethod new() FileDialog#
Creates a new
GtkFileDialogobject.Added in version 4.10.
Methods#
- class FileDialog
- get_accept_label() str | None#
Retrieves the text used by the dialog on its accept button.
Added in version 4.10.
- get_default_filter() FileFilter | None#
Gets the filter that will be selected by default in the file chooser dialog.
Added in version 4.10.
- get_filters() ListModel | None#
Gets the filters that will be offered to the user in the file chooser dialog.
Added in version 4.10.
- get_initial_file() File | None#
Gets the file that will be initially selected in the file chooser dialog.
Added in version 4.10.
- get_initial_folder() File | None#
Gets the folder that will be set as the initial folder in the file chooser dialog.
Added in version 4.10.
- get_initial_name() str | None#
Gets the name for the file that should be initially set.
Added in version 4.10.
- get_modal() bool#
Returns whether the file chooser dialog blocks interaction with the parent window while it is presented.
Added in version 4.10.
- get_title() str#
Returns the title that will be shown on the file chooser dialog.
Added in version 4.10.
- async open(self, parent: Window | None = None) File | None#
This is the awaitable version of
open().Added in version 4.10.
- Parameters:
parent – the parent
GtkWindow
- open(parent: Window | None = None, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
This function initiates a file selection operation by presenting a file chooser dialog to the user.
The
callbackwill be called when the dialog is dismissed.Added in version 4.10.
- Parameters:
parent – the parent
GtkWindowcancellable – a
GCancellableto cancel the operationcallback – a callback to call when the operation is complete
user_data – data to pass to
callback
- open_finish(result: AsyncResult) File | None#
Finishes the
opencall and returns the resulting file.Added in version 4.10.
- Parameters:
result – a
GAsyncResult
- async open_multiple(self, parent: Window | None = None) ListModel | None#
This is the awaitable version of
open_multiple().Added in version 4.10.
- Parameters:
parent – the parent
GtkWindow
- open_multiple(parent: Window | None = None, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
This function initiates a multi-file selection operation by presenting a file chooser dialog to the user.
The file chooser will initially be opened in the directory
initial_folder.The
callbackwill be called when the dialog is dismissed.Added in version 4.10.
- Parameters:
parent – the parent
GtkWindowcancellable – a
GCancellableto cancel the operationcallback – a callback to call when the operation is complete
user_data – data to pass to
callback
- open_multiple_finish(result: AsyncResult) ListModel | None#
Finishes the
opencall and returns the resulting files in aGListModel.Added in version 4.10.
- Parameters:
result – a
GAsyncResult
- async save(self, parent: Window | None = None) File | None#
This is the awaitable version of
save().Added in version 4.10.
- Parameters:
parent – the parent
GtkWindow
- save(parent: Window | None = None, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
This function initiates a file save operation by presenting a file chooser dialog to the user.
The
callbackwill be called when the dialog is dismissed.Added in version 4.10.
- Parameters:
parent – the parent
GtkWindowcancellable – a
GCancellableto cancel the operationcallback – a callback to call when the operation is complete
user_data – data to pass to
callback
- save_finish(result: AsyncResult) File | None#
Finishes the
savecall and returns the resulting file.Added in version 4.10.
- Parameters:
result – a
GAsyncResult
- async select_folder(self, parent: Window | None = None) File | None#
This is the awaitable version of
select_folder().Added in version 4.10.
- Parameters:
parent – the parent
GtkWindow
- select_folder(parent: Window | None = None, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
This function initiates a directory selection operation by presenting a file chooser dialog to the user.
If you pass
initial_folder, the file chooser will initially be opened in the parent directory of that folder, otherwise, it will be in the directoryinitial_folder.The
callbackwill be called when the dialog is dismissed.Added in version 4.10.
- Parameters:
parent – the parent
GtkWindowcancellable – a
GCancellableto cancel the operationcallback – a callback to call when the operation is complete
user_data – data to pass to
callback
- select_folder_finish(result: AsyncResult) File | None#
Finishes the
select_foldercall and returns the resulting file.Added in version 4.10.
- Parameters:
result – a
GAsyncResult
- async select_multiple_folders(self, parent: Window | None = None) ListModel | None#
This is the awaitable version of
select_multiple_folders().Added in version 4.10.
- Parameters:
parent – the parent
GtkWindow
- select_multiple_folders(parent: Window | None = None, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
This function initiates a multi-directory selection operation by presenting a file chooser dialog to the user.
The file chooser will initially be opened in the directory
initial_folder.The
callbackwill be called when the dialog is dismissed.Added in version 4.10.
- Parameters:
parent – the parent
GtkWindowcancellable – a
GCancellableto cancel the operationcallback – a callback to call when the operation is complete
user_data – data to pass to
callback
- select_multiple_folders_finish(result: AsyncResult) ListModel | None#
Finishes the
select_multiple_folderscall and returns the resulting files in aGListModel.Added in version 4.10.
- Parameters:
result – a
GAsyncResult
- set_accept_label(accept_label: str | None = None) None#
Sets the label shown on the file chooser’s accept button.
Leaving the accept label unset or setting it as
NULLwill fall back to a default label, depending on what API is used to launch the file dialog.Added in version 4.10.
- Parameters:
accept_label – the new accept label
- set_default_filter(filter: FileFilter | None = None) None#
Sets the filter that will be selected by default in the file chooser dialog.
If set to
None, the first item infilterswill be used as the default filter. If that list is empty, the dialog will be unfiltered.Added in version 4.10.
- Parameters:
filter – a
GtkFileFilter
- set_filters(filters: ListModel | None = None) None#
Sets the filters that will be offered to the user in the file chooser dialog.
Added in version 4.10.
- Parameters:
filters – a
GListModelofGtkFileFilters
- set_initial_file(file: File | None = None) None#
Sets the file that will be initially selected in the file chooser dialog.
This function is a shortcut for calling both
set_initial_folder()andset_initial_name()with the directory and name offilerespectively.Added in version 4.10.
- Parameters:
file – a
GFile
- set_initial_folder(folder: File | None = None) None#
Sets the folder that will be set as the initial folder in the file chooser dialog.
Added in version 4.10.
- Parameters:
folder – a
GFile
- set_initial_name(name: str | None = None) None#
Sets the name for the file that should be initially set. For saving dialogs, this will usually be pre-entered into the name field.
If a file with this name already exists in the directory set via
initial_folder, the dialog should preselect it.Added in version 4.10.
- Parameters:
name – a UTF8 string
Properties#
- class FileDialog
-
- props.default_filter: FileFilter#
The type of the None singleton.
Added in version 4.10.