Skip to content

Gtk.PrintOperationPreview

interface

The interface that is used to implement print preview.

A GtkPrintOperationPreview object is passed to the PrintOperation.preview signal by PrintOperation.

Methods

end_preview

def end_preview(self) -> None

Ends a preview.

This function must be called to finish a custom print preview.

is_selected

def is_selected(self, page_nr: int) -> bool

Returns whether the given page is included in the set of pages that have been selected for printing.

Parameters:

  • page_nr — a page number

render_page

def render_page(self, page_nr: int) -> None

Renders a page to the preview.

This is using the print context that was passed to the PrintOperation.preview handler together with preview.

A custom print preview should use this function to render the currently selected page.

Note that this function requires a suitable cairo context to be associated with the print context.

Parameters:

  • page_nr — the page to render

Virtual methods

do_end_preview

def do_end_preview(self) -> None

Ends a preview.

This function must be called to finish a custom print preview.

do_got_page_size

def do_got_page_size(self, context: PrintContext, page_setup: PageSetup) -> None

do_is_selected

def do_is_selected(self, page_nr: int) -> bool

Returns whether the given page is included in the set of pages that have been selected for printing.

Parameters:

  • page_nr — a page number

do_ready

def do_ready(self, context: PrintContext) -> None

do_render_page

def do_render_page(self, page_nr: int) -> None

Renders a page to the preview.

This is using the print context that was passed to the PrintOperation.preview handler together with preview.

A custom print preview should use this function to render the currently selected page.

Note that this function requires a suitable cairo context to be associated with the print context.

Parameters:

  • page_nr — the page to render

Signals

got-page-size

def on_got_page_size(self, context: PrintContext, page_setup: PageSetup) -> None: ...

Emitted once for each page that gets rendered to the preview.

A handler for this signal should update the context according to page_setup and set up a suitable cairo context, using PrintContext.set_cairo_context.

ready

def on_ready(self, context: PrintContext) -> None: ...

The ::ready signal gets emitted once per preview operation, before the first page is rendered.

A handler for this signal can be used for setup tasks.