PrintDialog#
Added in version 4.14.
Superclasses: Object
A GtkPrintDialog object collects the arguments that
are needed to present a print dialog to the user, such
as a title for the dialog and whether it should be modal.
The dialog is shown with the setup function.
The actual printing can be done with print or
print_file. These APIs follows the GIO async pattern,
and the results can be obtained by calling the corresponding finish methods.
Constructors#
- class PrintDialog
- classmethod new() PrintDialog#
Creates a new
GtkPrintDialogobject.Added in version 4.14.
Methods#
- class PrintDialog
- get_accept_label() str#
Returns the label that will be shown on the accept button of the print dialog.
Added in version 4.14.
- get_modal() bool#
Returns whether the print dialog blocks interaction with the parent window while it is presented.
Added in version 4.14.
- get_print_settings() PrintSettings | None#
Returns the print settings for the print dialog.
Added in version 4.14.
- async print_(self, parent: Window | None = None, setup: PrintSetup | None = None) OutputStream#
This is the awaitable version of
print_().- Parameters:
parent
setup
- print_(parent: Window | None = None, setup: PrintSetup | None = None, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
- Parameters:
parent
setup
cancellable
callback
user_data
- async print_file(self, parent: Window | None, setup: PrintSetup | None, file: File) bool#
This is the awaitable version of
print_file().Added in version 4.14.
- Parameters:
parent – the parent
GtkWindowsetup – the
GtkPrintSetupto usefile – the
GFileto print
- print_file(parent: Window | None, setup: PrintSetup | None, file: File, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
This function prints a file.
If you pass
NULLassetup, then this method will present a print dialog. Otherwise, it will attempt to print directly, without user interaction.Added in version 4.14.
- Parameters:
parent – the parent
GtkWindowsetup – the
GtkPrintSetupto usefile – the
GFileto printcancellable – a
GCancellableto cancel the operationcallback – a callback to call when the operation is complete
user_data – data to pass to
callback
- print_file_finish(result: AsyncResult) bool#
Finishes the
print_filecall and returns the results.Added in version 4.14.
- Parameters:
result – a
GAsyncResult
- print_finish(result: AsyncResult) OutputStream#
Finishes the
printcall and returns the results.If the call was successful, the content to be printed should be written to the returned output stream. Otherwise,
NULLis returned.The overall results of the print operation will be returned in the
closecall, so if you are interested in the results, you need to explicitly close the output stream (it will be closed automatically if you just unref it). Be aware that the close call may not be instant as it operation will for the printer to finish printing.Added in version 4.14.
- Parameters:
result – a
GAsyncResult
- set_accept_label(accept_label: str) None#
Sets the label that will be shown on the accept button of the print dialog shown for
setup.Added in version 4.14.
- Parameters:
accept_label – the new accept label
- set_modal(modal: bool) None#
Sets whether the print dialog blocks interaction with the parent window while it is presented.
Added in version 4.14.
- Parameters:
modal – the new value
- set_page_setup(page_setup: PageSetup) None#
Set the page setup for the print dialog.
Added in version 4.14.
- Parameters:
page_setup – the new page setup
- set_print_settings(print_settings: PrintSettings) None#
Sets the print settings for the print dialog.
Added in version 4.14.
- Parameters:
print_settings – the new print settings
- set_title(title: str) None#
Sets the title that will be shown on the print dialog.
Added in version 4.14.
- Parameters:
title – the new title
- async setup(self, parent: Window | None = None) PrintSetup#
This is the awaitable version of
setup().Added in version 4.14.
- Parameters:
parent – the parent
GtkWindow
- setup(parent: Window | None = None, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
This function presents a print dialog to let the user select a printer, and set up print settings and page setup.
The
callbackwill be called when the dialog is dismissed. The obtainedPrintSetupcan then be passed toprintorprint_file.One possible use for this method is to have the user select a printer, then show a page setup UI in the application (e.g. to arrange images on a page), then call
printonselfto do the printing without further user interaction.Added in version 4.14.
- 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
- setup_finish(result: AsyncResult) PrintSetup#
Finishes the
setupcall.If the call was successful, it returns a
PrintSetupwhich contains the print settings and page setup information that will be used to print.Added in version 4.14.
- Parameters:
result – a
GAsyncResult
Properties#
- class PrintDialog
-
- props.print_settings: PrintSettings#
The type of the None singleton.
Added in version 4.14.