Printer

class Printer(**properties: Any)

Superclasses: Object

A GtkPrinter object represents a printer.

You only need to deal directly with printers if you use the non-portable PrintUnixDialog API.

A GtkPrinter allows to get status information about the printer, such as its description, its location, the number of queued jobs, etc. Most importantly, a GtkPrinter object can be used to create a PrintJob object, which lets you print to the printer.

Constructors

class Printer
classmethod new(name: str, backend: PrintBackend, virtual_: bool) Printer

Creates a new GtkPrinter.

Parameters:
  • name – the name of the printer

  • backend – a GtkPrintBackend

  • virtual – whether the printer is virtual

Methods

class Printer
accepts_pdf() bool

Returns whether the printer accepts input in PDF format.

accepts_ps() bool

Returns whether the printer accepts input in PostScript format.

compare(b: Printer) int

Compares two printers.

Parameters:

b – another GtkPrinter

get_backend() PrintBackend

Returns the backend of the printer.

get_capabilities() PrintCapabilities

Returns the printer’s capabilities.

This is useful when you’re using GtkPrintUnixDialog’s manual-capabilities setting and need to know which settings the printer can handle and which you must handle yourself.

This will return 0 unless the printer’s details are available, see has_details and request_details.

get_default_page_size() PageSetup

Returns default page size of printer.

get_description() str

Gets the description of the printer.

get_hard_margins() tuple[bool, float, float, float, float]

Retrieve the hard margins of printer.

These are the margins that define the area at the borders of the paper that the printer cannot print to.

Note: This will not succeed unless the printer’s details are available, see has_details and request_details.

get_hard_margins_for_paper_size(paper_size: PaperSize) tuple[bool, float, float, float, float]

Retrieve the hard margins of printer for paper_size.

These are the margins that define the area at the borders of the paper that the printer cannot print to.

Note: This will not succeed unless the printer’s details are available, see has_details and request_details.

Parameters:

paper_size – a GtkPaperSize

get_icon_name() str

Gets the name of the icon to use for the printer.

get_job_count() int

Gets the number of jobs currently queued on the printer.

get_location() str

Returns a description of the location of the printer.

get_name() str

Returns the name of the printer.

get_state_message() str

Returns the state message describing the current state of the printer.

has_details() bool

Returns whether the printer details are available.

is_accepting_jobs() bool

Returns whether the printer is accepting jobs

is_active() bool

Returns whether the printer is currently active (i.e. accepts new jobs).

is_default() bool

Returns whether the printer is the default printer.

is_paused() bool

Returns whether the printer is currently paused.

A paused printer still accepts jobs, but it is not printing them.

is_virtual() bool

Returns whether the printer is virtual (i.e. does not represent actual printer hardware, but something like a CUPS class).

list_papers() list[PageSetup]

Lists all the paper sizes printer supports.

This will return and empty list unless the printer’s details are available, see has_details and request_details.

request_details() None

Requests the printer details.

When the details are available, the details_acquired signal will be emitted on printer.

Properties

class Printer
props.accepting_jobs: bool

True if the printer is accepting jobs.

props.accepts_pdf: bool

True if this printer can accept PDF.

props.accepts_ps: bool

True if this printer can accept PostScript.

props.icon_name: str

Icon name to use for the printer.

props.is_virtual: bool

False if this represents a real hardware device.

props.job_count: int

Number of jobs queued in the printer.

props.location: str

Information about the location of the printer.

props.name: str

The name of the printer.

props.paused: bool

True if this printer is paused.

A paused printer still accepts jobs, but it does not print them.

props.state_message: str

String giving the current status of the printer.

Signals

class Printer.signals
details_acquired(success: bool) None

Emitted in response to a request for detailed information about a printer from the print backend.

The success parameter indicates if the information was actually obtained.

Parameters:

successTrue if the details were successfully acquired