Then you start the print operation by calling gtk.print_operation.PrintOperation.run.
It will then show a dialog, let the user select a printer and options.
When the user finished the dialog, various signals will be emitted on
the gtk.print_operation.PrintOperation, the main one being
signal@Gtk.PrintOperation::draw-page, which you are supposed to handle
and render the page on the provided gtk.print_context.PrintContext using Cairo.
gtk.print_operation.PrintOperation is the high-level, portable printing API.
It looks a bit different than other GTK dialogs such as the gtk.file_chooser.FileChooser, since some platforms don’t expose enough infrastructure to implement a good print dialog. On such platforms, gtk.print_operation.PrintOperation uses the native print dialog. On platforms which do not provide a native print dialog, GTK uses its own, see gtk.print_unix_dialog.PrintUnixDialog.
The typical way to use the high-level printing API is to create a gtk.print_operation.PrintOperation object with gtk.print_operation.PrintOperation.new_ when the user selects to print. Then you set some properties on it, e.g. the page size, any gtk.print_settings.PrintSettings from previous print operations, the number of pages, the current page, etc.
Then you start the print operation by calling gtk.print_operation.PrintOperation.run. It will then show a dialog, let the user select a printer and options. When the user finished the dialog, various signals will be emitted on the gtk.print_operation.PrintOperation, the main one being signal@Gtk.PrintOperation::draw-page, which you are supposed to handle and render the page on the provided gtk.print_context.PrintContext using Cairo.
The high-level printing API
By default gtk.print_operation.PrintOperation uses an external application to do print preview. To implement a custom print preview, an application must connect to the preview signal. The functions gtk.print_operation_preview.PrintOperationPreview.renderPage, gtk.print_operation_preview.PrintOperationPreview.endPreview and gtk.print_operation_preview.PrintOperationPreview.isSelected
are useful when implementing a print preview.