Gtk.PrintDialog

g GObject.Object GObject.Object Gtk.PrintDialog Gtk.PrintDialog GObject.Object->Gtk.PrintDialog

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

get_accept_label ()

get_modal ()

get_page_setup ()

get_print_settings ()

get_title ()

print_ (parent, setup, cancellable, callback, *user_data)

print_file (parent, setup, file, cancellable, callback, *user_data)

print_file_finish (result)

print_finish (result)

set_accept_label (accept_label)

set_modal (modal)

set_page_setup (page_setup)

set_print_settings (print_settings)

set_title (title)

setup (parent, cancellable, callback, *user_data)

setup_finish (result)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

accept-label

str

r/w/en

modal

bool

r/w/en

page-setup

Gtk.PageSetup

r/w/en

print-settings

Gtk.PrintSettings

r/w/en

title

str

r/w/en

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class Gtk.PrintDialog(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Gtk.PrintDialogClass

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 [method`Gtk`.PrintDialog.setup] function. The actual printing can be done with [method`Gtk`.PrintDialog.print] or [method`Gtk`.PrintDialog.print_file]. These APIs follows the GIO async pattern, and the results can be obtained by calling the corresponding finish methods.

New in version 4.14.

classmethod new()[source]
Returns:

the new GtkPrintDialog

Return type:

Gtk.PrintDialog

Creates a new GtkPrintDialog object.

New in version 4.14.

get_accept_label()[source]
Returns:

the accept label

Return type:

str

Returns the label that will be shown on the accept button of the print dialog.

New in version 4.14.

get_modal()[source]
Returns:

whether the print dialog is modal

Return type:

bool

Returns whether the print dialog blocks interaction with the parent window while it is presented.

New in version 4.14.

get_page_setup()[source]
Returns:

the page setup

Return type:

Gtk.PageSetup or None

Returns the page setup.

New in version 4.14.

get_print_settings()[source]
Returns:

the settings

Return type:

Gtk.PrintSettings or None

Returns the print settings for the print dialog.

New in version 4.14.

get_title()[source]
Returns:

the title

Return type:

str

Returns the title that will be shown on the print dialog.

New in version 4.14.

print_(parent, setup, cancellable, callback, *user_data)[source]
Parameters:

This function prints content from a stream.

If you pass NULL as setup, then this method will present a print dialog. Otherwise, it will attempt to print directly, without user interaction.

The callback will be called when the printing is done.

New in version 4.14.

print_file(parent, setup, file, cancellable, callback, *user_data)[source]
Parameters:

This function prints a file.

If you pass NULL as setup, then this method will present a print dialog. Otherwise, it will attempt to print directly, without user interaction.

New in version 4.14.

print_file_finish(result)[source]
Parameters:

result (Gio.AsyncResult) – a GAsyncResult

Raises:

GLib.Error

Returns:

Whether the call was successful

Return type:

bool

Finishes the [method`Gtk`.PrintDialog.print_file] call and returns the results.

New in version 4.14.

print_finish(result)[source]
Parameters:

result (Gio.AsyncResult) – a GAsyncResult

Raises:

GLib.Error

Returns:

a [class`Gio`.OutputStream]

Return type:

Gio.OutputStream

Finishes the [method`Gtk`.PrintDialog.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 [method`Gio`.OutputStream.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.

New in version 4.14.

set_accept_label(accept_label)[source]
Parameters:

accept_label (str) – the new accept label

Sets the label that will be shown on the accept button of the print dialog shown for [method`Gtk`.PrintDialog.setup].

New in version 4.14.

set_modal(modal)[source]
Parameters:

modal (bool) – the new value

Sets whether the print dialog blocks interaction with the parent window while it is presented.

New in version 4.14.

set_page_setup(page_setup)[source]
Parameters:

page_setup (Gtk.PageSetup) – the new page setup

Set the page setup for the print dialog.

New in version 4.14.

set_print_settings(print_settings)[source]
Parameters:

print_settings (Gtk.PrintSettings) – the new print settings

Sets the print settings for the print dialog.

New in version 4.14.

set_title(title)[source]
Parameters:

title (str) – the new title

Sets the title that will be shown on the print dialog.

New in version 4.14.

setup(parent, cancellable, callback, *user_data)[source]
Parameters:

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 obtained [struct`Gtk`.PrintSetup] can then be passed to [method`Gtk`.PrintDialog.print] or [method`Gtk`.PrintDialog.print_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 [method`Gtk`.PrintDialog.print] on self to do the printing without further user interaction.

New in version 4.14.

setup_finish(result)[source]
Parameters:

result (Gio.AsyncResult) – a GAsyncResult

Raises:

GLib.Error

Returns:

The GtkPrintSetup object that resulted from the call, or NULL if the call was not successful

Return type:

Gtk.PrintSetup

Finishes the [method`Gtk`.PrintDialog.setup] call.

If the call was successful, it returns a [struct`Gtk`.PrintSetup] which contains the print settings and page setup information that will be used to print.

New in version 4.14.

Property Details

Gtk.PrintDialog.props.accept_label
Name:

accept-label

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

A label that may be shown on the accept button of a print dialog that is presented by [method`Gtk`.PrintDialog.setup].

New in version 4.14.

Gtk.PrintDialog.props.modal
Name:

modal

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether the print dialog is modal.

New in version 4.14.

Gtk.PrintDialog.props.page_setup
Name:

page-setup

Type:

Gtk.PageSetup

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The page setup to use.

New in version 4.14.

Gtk.PrintDialog.props.print_settings
Name:

print-settings

Type:

Gtk.PrintSettings

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The print settings to use.

New in version 4.14.

Gtk.PrintDialog.props.title
Name:

title

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

A title that may be shown on the print dialog that is presented by [method`Gtk`.PrintDialog.setup].

New in version 4.14.