PrintUnixDialog

class PrintUnixDialog(*args, **kwargs)

Superclasses: Dialog, Window, Widget, InitiallyUnowned, Object

Implemented Interfaces: Accessible, Buildable, ConstraintTarget, Native, Root, ShortcutManager

GtkPrintUnixDialog implements a print dialog for platforms which don’t provide a native print dialog, like Unix.

https://docs.gtk.org/gtk4/printdialog.png

It can be used very much like any other GTK dialog, at the cost of the portability offered by the high-level printing API with PrintOperation.

In order to print something with GtkPrintUnixDialog, you need to use get_selected_printer to obtain a Printer object and use it to construct a PrintJob using new.

GtkPrintUnixDialog uses the following response values:

  • OK: for the “Print” button

  • APPLY: for the “Preview” button

  • CANCEL: for the “Cancel” button

GtkPrintUnixDialog as GtkBuildable

The GtkPrintUnixDialog implementation of the GtkBuildable interface exposes its notebook internal children with the name “notebook”.

An example of a GtkPrintUnixDialog UI definition fragment:

<object class="GtkPrintUnixDialog" id="dialog1">
  <child internal-child="notebook">
    <object class="GtkNotebook" id="notebook">
      <child>
        <object type="GtkNotebookPage">
          <property name="tab_expand">False</property>
          <property name="tab_fill">False</property>
          <property name="tab">
            <object class="GtkLabel" id="tablabel">
              <property name="label">Tab label</property>
            </object>
          </property>
          <property name="child">
            <object class="GtkLabel" id="tabcontent">
              <property name="label">Content on notebook tab</property>
            </object>
          </property>
        </object>
      </child>
    </object>
  </child>
</object>

CSS nodes

GtkPrintUnixDialog has a single CSS node with name window. The style classes dialog and print are added.

Constructors

class PrintUnixDialog
classmethod new(title: str | None = None, parent: Window | None = None) Widget

Creates a new GtkPrintUnixDialog.

Parameters:
  • title – Title of the dialog

  • parent – Transient parent of the dialog

Methods

class PrintUnixDialog
add_custom_tab(child: Widget, tab_label: Widget) None

Adds a custom tab to the print dialog.

Parameters:
  • child – the widget to put in the custom tab

  • tab_label – the widget to use as tab label

get_current_page() int

Gets the current page of the GtkPrintUnixDialog.

get_embed_page_setup() bool

Gets whether to embed the page setup.

get_has_selection() bool

Gets whether there is a selection.

get_manual_capabilities() PrintCapabilities

Gets the capabilities that have been set on this GtkPrintUnixDialog.

get_page_setup() PageSetup

Gets the page setup that is used by the GtkPrintUnixDialog.

get_page_setup_set() bool

Gets whether a page setup was set by the user.

get_selected_printer() Printer | None

Gets the currently selected printer.

get_settings() PrintSettings

Gets a new GtkPrintSettings object that represents the current values in the print dialog.

Note that this creates a new object, and you need to unref it if don’t want to keep it.

get_support_selection() bool

Gets whether the print dialog allows user to print a selection.

set_current_page(current_page: int) None

Sets the current page number.

If current_page is not -1, this enables the current page choice for the range of pages to print.

Parameters:

current_page – the current page number.

set_embed_page_setup(embed: bool) None

Embed page size combo box and orientation combo box into page setup page.

Parameters:

embed – embed page setup selection

set_has_selection(has_selection: bool) None

Sets whether a selection exists.

Parameters:

has_selectionTrue indicates that a selection exists

set_manual_capabilities(capabilities: PrintCapabilities) None

This lets you specify the printing capabilities your application supports.

For instance, if you can handle scaling the output then you pass SCALE. If you don’t pass that, then the dialog will only let you select the scale if the printing system automatically handles scaling.

Parameters:

capabilities – the printing capabilities of your application

set_page_setup(page_setup: PageSetup) None

Sets the page setup of the GtkPrintUnixDialog.

Parameters:

page_setup – a GtkPageSetup

set_settings(settings: PrintSettings | None = None) None

Sets the GtkPrintSettings for the GtkPrintUnixDialog.

Typically, this is used to restore saved print settings from a previous print operation before the print dialog is shown.

Parameters:

settings – a GtkPrintSettings

set_support_selection(support_selection: bool) None

Sets whether the print dialog allows user to print a selection.

Parameters:

support_selectionTrue to allow print selection

Properties

class PrintUnixDialog
props.current_page: int

The current page in the document.

props.embed_page_setup: bool

True if the page setup controls are embedded.

props.has_selection: bool

Whether the application has a selection.

props.manual_capabilities: PrintCapabilities

Capabilities the application can handle.

props.page_setup: PageSetup

The GtkPageSetup object to use.

props.print_settings: PrintSettings

The GtkPrintSettings object used for this dialog.

props.selected_printer: Printer

The GtkPrinter which is selected.

props.support_selection: bool

Whether the dialog supports selection.