Gtk.PrintJob

g GObject.Object GObject.Object Gtk.PrintJob Gtk.PrintJob GObject.Object->Gtk.PrintJob

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new (title, printer, settings, page_setup)

get_collate ()

get_n_up ()

get_n_up_layout ()

get_num_copies ()

get_page_ranges ()

get_page_set ()

get_pages ()

get_printer ()

get_reverse ()

get_rotate ()

get_scale ()

get_settings ()

get_status ()

get_surface ()

get_title ()

get_track_print_status ()

send (callback, *user_data)

set_collate (collate)

set_n_up (n_up)

set_n_up_layout (layout)

set_num_copies (num_copies)

set_page_ranges (ranges)

set_page_set (page_set)

set_pages (pages)

set_reverse (reverse)

set_rotate (rotate)

set_scale (scale)

set_source_fd (fd)

set_source_file (filename)

set_track_print_status (track_status)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

page-setup

Gtk.PageSetup

r/w/co

printer

Gtk.Printer

r/w/co

settings

Gtk.PrintSettings

r/w/co

title

str

r/w/co

track-print-status

bool

r/w

Signals

Inherited:

GObject.Object (1)

Name

Short Description

status-changed

Emitted when the status of a job changes.

Fields

Inherited:

GObject.Object (1)

Class Details

class Gtk.PrintJob(**kwargs)
Bases:

GObject.Object

Abstract:

No

A GtkPrintJob object represents a job that is sent to a printer.

You only need to deal directly with print jobs if you use the non-portable [class`Gtk`.PrintUnixDialog] API.

Use [method`Gtk`.PrintJob.get_surface] to obtain the cairo surface onto which the pages must be drawn. Use [method`Gtk`.PrintJob.send] to send the finished job to the printer. If you don’t use cairo GtkPrintJob also supports printing of manually generated PostScript, via [method`Gtk`.PrintJob.set_source_file].

classmethod new(title, printer, settings, page_setup)[source]
Parameters:
Returns:

a new GtkPrintJob

Return type:

Gtk.PrintJob

Creates a new GtkPrintJob.

get_collate()[source]
Returns:

whether the job is printed collated

Return type:

bool

Gets whether this job is printed collated.

get_n_up()[source]
Returns:

the n-up setting

Return type:

int

Gets the n-up setting for this job.

get_n_up_layout()[source]
Returns:

the n-up layout

Return type:

Gtk.NumberUpLayout

Gets the n-up layout setting for this job.

get_num_copies()[source]
Returns:

the number of copies

Return type:

int

Gets the number of copies of this job.

get_page_ranges()[source]
Returns:

a pointer to an array of GtkPageRange structs

Return type:

[Gtk.PageRange]

Gets the page ranges for this job.

get_page_set()[source]
Returns:

the GtkPageSet setting

Return type:

Gtk.PageSet

Gets the GtkPageSet setting for this job.

get_pages()[source]
Returns:

the GtkPrintPages setting

Return type:

Gtk.PrintPages

Gets the GtkPrintPages setting for this job.

get_printer()[source]
Returns:

the printer of self

Return type:

Gtk.Printer

Gets the GtkPrinter of the print job.

get_reverse()[source]
Returns:

whether the job is printed reversed.

Return type:

bool

Gets whether this job is printed reversed.

get_rotate()[source]
Returns:

whether the job is printed rotated

Return type:

bool

Gets whether the job is printed rotated.

get_scale()[source]
Returns:

the scale

Return type:

float

Gets the scale for this job.

get_settings()[source]
Returns:

the settings of self

Return type:

Gtk.PrintSettings

Gets the GtkPrintSettings of the print job.

get_status()[source]
Returns:

the status of self

Return type:

Gtk.PrintStatus

Gets the status of the print job.

get_surface()[source]
Raises:

GLib.Error

Returns:

the cairo surface of self

Return type:

cairo.Surface

Gets a cairo surface onto which the pages of the print job should be rendered.

get_title()[source]
Returns:

the title of self

Return type:

str

Gets the job title.

get_track_print_status()[source]
Returns:

True if print job status will be reported after printing

Return type:

bool

Returns whether jobs will be tracked after printing.

For details, see [method`Gtk`.PrintJob.set_track_print_status].

send(callback, *user_data)[source]
Parameters:
  • callback (Gtk.PrintJobCompleteFunc) – function to call when the job completes or an error occurs

  • user_data (object or None) – user data that gets passed to callback

Sends the print job off to the printer.

set_collate(collate)[source]
Parameters:

collate (bool) – whether the job is printed collated

Sets whether this job is printed collated.

set_n_up(n_up)[source]
Parameters:

n_up (int) – the n-up value

Sets the n-up setting for this job.

set_n_up_layout(layout)[source]
Parameters:

layout (Gtk.NumberUpLayout) – the n-up layout setting

Sets the n-up layout setting for this job.

set_num_copies(num_copies)[source]
Parameters:

num_copies (int) – the number of copies

Sets the number of copies for this job.

set_page_ranges(ranges)[source]
Parameters:

ranges ([Gtk.PageRange]) – pointer to an array of GtkPageRange structs

Sets the page ranges for this job.

set_page_set(page_set)[source]
Parameters:

page_set (Gtk.PageSet) – a GtkPageSet setting

Sets the GtkPageSet setting for this job.

set_pages(pages)[source]
Parameters:

pages (Gtk.PrintPages) – the GtkPrintPages setting

Sets the GtkPrintPages setting for this job.

set_reverse(reverse)[source]
Parameters:

reverse (bool) – whether the job is printed reversed

Sets whether this job is printed reversed.

set_rotate(rotate)[source]
Parameters:

rotate (bool) – whether to print rotated

Sets whether this job is printed rotated.

set_scale(scale)[source]
Parameters:

scale (float) – the scale

Sets the scale for this job.

1.0 means unscaled.

set_source_fd(fd)[source]
Parameters:

fd (int) – a file descriptor

Raises:

GLib.Error

Returns:

False if an error occurred

Return type:

bool

Make the GtkPrintJob send an existing document to the printing system.

The file can be in any format understood by the platforms printing system (typically PostScript, but on many platforms PDF may work too). See [method`Gtk`.Printer.accepts_pdf] and [method`Gtk`.Printer.accepts_ps].

This is similar to [method`Gtk`.PrintJob.set_source_file], but takes expects an open file descriptor for the file, instead of a filename.

set_source_file(filename)[source]
Parameters:

filename (str) – the file to be printed

Raises:

GLib.Error

Returns:

False if an error occurred

Return type:

bool

Make the GtkPrintJob send an existing document to the printing system.

The file can be in any format understood by the platforms printing system (typically PostScript, but on many platforms PDF may work too). See [method`Gtk`.Printer.accepts_pdf] and [method`Gtk`.Printer.accepts_ps].

set_track_print_status(track_status)[source]
Parameters:

track_status (bool) – True to track status after printing

If track_status is True, the print job will try to continue report on the status of the print job in the printer queues and printer.

This can allow your application to show things like “out of paper” issues, and when the print job actually reaches the printer.

This function is often implemented using some form of polling, so it should not be enabled unless needed.

Signal Details

Gtk.PrintJob.signals.status_changed(print_job)
Signal Name:

status-changed

Flags:

RUN_LAST

Parameters:

print_job (Gtk.PrintJob) – The object which received the signal

Emitted when the status of a job changes.

The signal handler can use [method`Gtk`.PrintJob.get_status] to obtain the new status.

Property Details

Gtk.PrintJob.props.page_setup
Name:

page-setup

Type:

Gtk.PageSetup

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Page setup.

Gtk.PrintJob.props.printer
Name:

printer

Type:

Gtk.Printer

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The printer to send the job to.

Gtk.PrintJob.props.settings
Name:

settings

Type:

Gtk.PrintSettings

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Printer settings.

Gtk.PrintJob.props.title
Name:

title

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The title of the print job.

Gtk.PrintJob.props.track_print_status
Name:

track-print-status

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

True if the print job will continue to emit status-changed signals after the print data has been setn to the printer.