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
GtkPrintDialog
object.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.
- print_(parent: Window | None = None, setup: PrintSetup | None = None, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None #
- Parameters:
parent
setup
cancellable
callback
user_data
- print_file(parent: Window | None, setup: PrintSetup | None, file: File, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None #
This function prints a file.
If you pass
NULL
assetup
, 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
GtkWindow
setup – the
GtkPrintSetup
to usefile – the
GFile
to printcancellable – a
GCancellable
to 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_file
call and returns the results.Added in version 4.14.
- Parameters:
result – a
GAsyncResult
- print_finish(result: AsyncResult) OutputStream #
Finishes the
print
call and returns the results.If the call was successful, the content to be printed should be written to the returned output stream. Otherwise,
NULL
is returned.The overall results of the print operation will be returned in the
close
call, 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
- setup(parent: Window | None = None, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None #
This function presents a print dialog to let the user select a printer, and set up print settings and page setup.
The
callback
will be called when the dialog is dismissed. The obtainedPrintSetup
can then be passed toprint
orprint_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
print
onself
to do the printing without further user interaction.Added in version 4.14.
- Parameters:
parent – the parent
GtkWindow
cancellable – a
GCancellable
to 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
setup
call.If the call was successful, it returns a
PrintSetup
which 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.