:right-sidebar: True PrintUnixDialog =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: PrintUnixDialog(*args, **kwargs) :no-contents-entry: Superclasses: :class:`~gi.repository.Gtk.Dialog`, :class:`~gi.repository.Gtk.Window`, :class:`~gi.repository.Gtk.Widget`, :class:`~gi.repository.GObject.InitiallyUnowned`, :class:`~gi.repository.GObject.Object` Implemented Interfaces: :class:`~gi.repository.Gtk.Accessible`, :class:`~gi.repository.Gtk.Buildable`, :class:`~gi.repository.Gtk.ConstraintTarget`, :class:`~gi.repository.Gtk.Native`, :class:`~gi.repository.Gtk.Root`, :class:`~gi.repository.Gtk.ShortcutManager` ``GtkPrintUnixDialog`` implements a print dialog for platforms which don’t provide a native print dialog, like Unix. .. image:: 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 :obj:`~gi.repository.Gtk.PrintOperation`\. In order to print something with ``GtkPrintUnixDialog``\, you need to use :obj:`~gi.repository.Gtk.PrintUnixDialog.get_selected_printer` to obtain a :obj:`~gi.repository.Gtk.Printer` object and use it to construct a :obj:`~gi.repository.Gtk.PrintJob` using :obj:`~gi.repository.Gtk.PrintJob.new`\. ``GtkPrintUnixDialog`` uses the following response values: - :const:`~gi.repository.Gtk.ResponseType.OK`: for the “Print” button - :const:`~gi.repository.Gtk.ResponseType.APPLY`: for the “Preview” button - :const:`~gi.repository.Gtk.ResponseType.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: .. code-block:: xml :dedent: False False Tab label Content on notebook tab CSS nodes -------------------------------------------------------------------------------- ``GtkPrintUnixDialog`` has a single CSS node with name window. The style classes dialog and print are added. Constructors ------------ .. rst-class:: interim-class .. class:: PrintUnixDialog :no-index: .. classmethod:: new(title: str | None = None, parent: ~gi.repository.Gtk.Window | None = None) -> ~gi.repository.Gtk.Widget Creates a new ``GtkPrintUnixDialog``\. :param title: Title of the dialog :param parent: Transient parent of the dialog Methods ------- .. rst-class:: interim-class .. class:: PrintUnixDialog :no-index: .. method:: add_custom_tab(child: ~gi.repository.Gtk.Widget, tab_label: ~gi.repository.Gtk.Widget) -> None Adds a custom tab to the print dialog. :param child: the widget to put in the custom tab :param tab_label: the widget to use as tab label .. method:: get_current_page() -> int Gets the current page of the ``GtkPrintUnixDialog``\. .. method:: get_embed_page_setup() -> bool Gets whether to embed the page setup. .. method:: get_has_selection() -> bool Gets whether there is a selection. .. method:: get_manual_capabilities() -> ~gi.repository.Gtk.PrintCapabilities Gets the capabilities that have been set on this ``GtkPrintUnixDialog``\. .. method:: get_page_setup() -> ~gi.repository.Gtk.PageSetup Gets the page setup that is used by the ``GtkPrintUnixDialog``\. .. method:: get_page_setup_set() -> bool Gets whether a page setup was set by the user. .. method:: get_selected_printer() -> ~gi.repository.Gtk.Printer | None Gets the currently selected printer. .. method:: get_settings() -> ~gi.repository.Gtk.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. .. method:: get_support_selection() -> bool Gets whether the print dialog allows user to print a selection. .. method:: 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. :param current_page: the current page number. .. method:: set_embed_page_setup(embed: bool) -> None Embed page size combo box and orientation combo box into page setup page. :param embed: embed page setup selection .. method:: set_has_selection(has_selection: bool) -> None Sets whether a selection exists. :param has_selection: :const:`True` indicates that a selection exists .. method:: set_manual_capabilities(capabilities: ~gi.repository.Gtk.PrintCapabilities) -> None This lets you specify the printing capabilities your application supports. For instance, if you can handle scaling the output then you pass :const:`~gi.repository.Gtk.PrintCapabilities.SCALE`. If you don’t pass that, then the dialog will only let you select the scale if the printing system automatically handles scaling. :param capabilities: the printing capabilities of your application .. method:: set_page_setup(page_setup: ~gi.repository.Gtk.PageSetup) -> None Sets the page setup of the ``GtkPrintUnixDialog``\. :param page_setup: a ``GtkPageSetup`` .. method:: set_settings(settings: ~gi.repository.Gtk.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. :param settings: a ``GtkPrintSettings`` .. method:: set_support_selection(support_selection: bool) -> None Sets whether the print dialog allows user to print a selection. :param support_selection: :const:`True` to allow print selection Properties ---------- .. rst-class:: interim-class .. class:: PrintUnixDialog :no-index: .. attribute:: props.current_page :type: int The type of the None singleton. .. attribute:: props.embed_page_setup :type: bool The type of the None singleton. .. attribute:: props.has_selection :type: bool The type of the None singleton. .. attribute:: props.manual_capabilities :type: ~gi.repository.Gtk.PrintCapabilities The type of the None singleton. .. attribute:: props.page_setup :type: ~gi.repository.Gtk.PageSetup The type of the None singleton. .. attribute:: props.print_settings :type: ~gi.repository.Gtk.PrintSettings The type of the None singleton. .. attribute:: props.selected_printer :type: ~gi.repository.Gtk.Printer The type of the None singleton. .. attribute:: props.support_selection :type: bool The type of the None singleton.