gtkunixprint.PrintJob
Prev | The gtkunixprint Class Reference | Next

## gtkunixprint.PrintJob

gtkunixprint.PrintJob — an object that represents a print job (new in PyGTK 2.10)

## Synopsis

    class gtkunixprint.PrintJob(gobject.GObject):
        gtkunixprint.PrintJob(title, printer, settings, page_setup)
        def get_settings()
        def get_printer()
        def get_title()
        def get_status()
        def set_source_file(filename)
        def get_surface()
        def set_track_print_status(track_status)
        def get_track_print_status()
        def send(callback, user_data=None)

## Ancestry

    +-- gobject.GObject
      +-- gtkunixprint.PrintJob

## gtkunixprint.PrintJob Properties

"page-setup" | Read-Write-Construct Only | The Page Setup. Available in GTK+ 2.10.
"printer" | Read-Write-Construct Only | The Printer to print the job to. Available in GTK+ 2.10.
"settings" | Read-Write-Construct Only | The Printer Settings. Available in GTK+ 2.10.
"title" | Read-Write-Construct Only | Title of the print job. Default value: `None`. Available in GTK+ 2.10.
"track-print-status" | Read-Write | if `True` the print job will continue to emit status-changed signals after the print data has been sent to the printer or print server. Available in GTK+ 2.10.

## gtkunixprint.PrintJob Signal Prototypes

gobject.GObject Signal Prototypes

"status-changed" | `def callback(`printjob`, `user_param1`, `...`)`

## Description

### Note

This class is available in PyGTK 2.10 and above.

A `gtkunixprint.PrintJob` 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 `gtkunixprint.PrintUnixDialog` API.

Use the `get_surface`() method to obtain the cairo surface onto which the pages must be drawn. Use the `send`() method to send the finished job to the printer. If you don't use cairo `gtkunixprint.PrintJob` also supports printing of manually generated postscript, via the `set_source_file`() method.

## Constructor

### gtkunixprint.PrintJob

        gtkunixprint.PrintJob(title, printer, settings, page_setup)

`title` : | the job title
`printer` : | a `gtkunixprint.Printer`
`settings` : | a `gtk.PrintSettings`
`page_setup` : | a `gtk.PageSetup`
Returns : | a new `gtkunixprint.PrintJob`

### Note

This constructor is available in PyGTK 2.10 and above.

Creates a new `gtkunixprint.PrintJob`.

## Methods

### gtkunixprint.PrintJob.get_settings

        def get_settings()

Returns : | the settings of the print job

### Note

This method is available in PyGTK 2.10 and above.

The `get_settings`() method returns the `gtk.PrintSettings` of the print job.

### gtkunixprint.PrintJob.get_printer

        def get_printer()

Returns : | the printer of the print job

### Note

This method is available in PyGTK 2.10 and above.

The `get_printer`() method returns the `gtkunixprint.Printer` of the print job.

### gtkunixprint.PrintJob.get_title

        def get_title()

Returns : | the title of the print job

### Note

This method is available in PyGTK 2.10 and above.

The `get_title`() method returns the print job title.

### gtkunixprint.PrintJob.get_status

        def get_status()

Returns : | the status of the print job

### Note

This method is available in PyGTK 2.10 and above.

The `get_status`() method returns the status of the print job.

### gtkunixprint.PrintJob.set_source_file

        def set_source_file(filename)

`filename` : | the file to be printed
Returns : | `False` if an error occurred

### Note

This method is available in PyGTK 2.10 and above.

The `set_source_file`() method makes the `gtkunixprint.PrintJob` send the existing document specified by `filename` 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).

### gtkunixprint.PrintJob.get_surface

        def get_surface()

Returns : | the cairo surface of the print job

### Note

This method is available in PyGTK 2.10 and above.

The `get_surface`() method returns a cairo surface onto which the pages of the print job should be rendered.

### gtkunixprint.PrintJob.set_track_print_status

        def set_track_print_status(track_status)

`track_status` : | if `True` track the status of the print job after sending

### Note

This method is available in PyGTK 2.10 and above.

The `set_track_print_status`() method enable or disables tracking of the print job status based on the value specified by `track_status`. 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 method is often implemented using some form of polling, so tracking should not be enabled unless needed.

### gtkunixprint.PrintJob.get_track_print_status

        def get_track_print_status()

Returns : | `True` if print job status will be reported after printing

### Note

This method is available in PyGTK 2.10 and above.

The `get_track_print_status`() method returns wheter jobs will be tracked after printing. For details, see the `set_track_print_status()` method.

### gtkunixprint.PrintJob.send

        def send(callback, user_data=None)

`callback` : | the function to call when the job completes
`user_data` : | user data that gets passed to `callback`
Returns : | `False` if an error occurred

### Note

This method is available in PyGTK 2.10 and above.

The `send`() method sends the print job off to the printer and registers the function specified by `callback` ro be called when the job completes.

The signature of `callback` is:

    def callback(print_job, data, errormsg):

where `data` is `user_data` and `errormsg` is a message indicating what problem has occurred or `None` if no error has occurred.

## Signals

### The "status-changed" Signal

        def callback(gtkprintjob, user_param1, ...)

`gtkprintjob` : | the gtkprintjob that received the signal
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

The "status-changed" signal is emitted when the status of a job changes. The signal handler can use the `get_status`() method to obtain the new status.

Prev | Up | Next
gtkunixprint.Printer | Home | gtkunixprint.PrintUnixDialog