:right-sidebar: True PrintDialog =================================================================== .. currentmodule:: gi.repository.Gtk .. versionadded:: 4.14 .. class:: PrintDialog(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` A ``GtkPrintDialog`` object collects the arguments that are needed to present a print dialog to the user, such as a title for the dialog and whether it should be modal. The dialog is shown with the :obj:`~gi.repository.Gtk.PrintDialog.setup` function. The actual printing can be done with :obj:`~gi.repository.Gtk.PrintDialog.print` or :obj:`~gi.repository.Gtk.PrintDialog.print_file`. These APIs follows the GIO async pattern, and the results can be obtained by calling the corresponding finish methods. Constructors ------------ .. rst-class:: interim-class .. class:: PrintDialog :no-index: .. classmethod:: new() -> ~gi.repository.Gtk.PrintDialog Creates a new ``GtkPrintDialog`` object. .. versionadded:: 4.14 Methods ------- .. rst-class:: interim-class .. class:: PrintDialog :no-index: .. method:: get_accept_label() -> str Returns the label that will be shown on the accept button of the print dialog. .. versionadded:: 4.14 .. method:: get_modal() -> bool Returns whether the print dialog blocks interaction with the parent window while it is presented. .. versionadded:: 4.14 .. method:: get_page_setup() -> ~gi.repository.Gtk.PageSetup Returns the page setup. .. versionadded:: 4.14 .. method:: get_print_settings() -> ~gi.repository.Gtk.PrintSettings Returns the print settings for the print dialog. .. versionadded:: 4.14 .. method:: get_title() -> str Returns the title that will be shown on the print dialog. .. versionadded:: 4.14 .. method:: print_(parent: ~gi.repository.Gtk.Window | None = None, setup: ~gi.repository.Gtk.PrintSetup | None = None, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[...], None] | None = None, *user_data: ~typing.Any) -> None :param parent: :param setup: :param cancellable: :param callback: :param user_data: .. method:: print_file(parent: ~gi.repository.Gtk.Window | None, setup: ~gi.repository.Gtk.PrintSetup | None, file: ~gi.repository.Gio.File, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[...], None] | None = None, *user_data: ~typing.Any) -> None This function prints a file. If you pass ``NULL`` as ``setup``, then this method will present a print dialog. Otherwise, it will attempt to print directly, without user interaction. The ``callback`` will be called when the printing is done. It should call :obj:`~gi.repository.Gtk.PrintDialog.print_file_finish` to obtain the results. .. versionadded:: 4.14 :param parent: the parent ``GtkWindow`` :param setup: the ``GtkPrintSetup`` to use :param file: the ``GFile`` to print :param cancellable: a ``GCancellable`` to cancel the operation :param callback: a callback to call when the operation is complete :param user_data: data to pass to ``callback`` .. method:: print_file_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes the :obj:`~gi.repository.Gtk.PrintDialog.print_file` call and returns the results. .. versionadded:: 4.14 :param result: a ``GAsyncResult`` .. method:: print_finish(result: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gio.OutputStream | None Finishes the :obj:`~gi.repository.Gtk.PrintDialog.print` call and returns the results. If the call was successful, the content to be printed should be written to the returned output stream. Otherwise, ``NULL`` is returned. The overall results of the print operation will be returned in the :obj:`~gi.repository.Gio.OutputStream.close` call, so if you are interested in the results, you need to explicitly close the output stream (it will be closed automatically if you just unref it). Be aware that the close call may not be instant as it operation will for the printer to finish printing. .. versionadded:: 4.14 :param result: a ``GAsyncResult`` .. method:: set_accept_label(accept_label: str) -> None Sets the label that will be shown on the accept button of the print dialog shown for :obj:`~gi.repository.Gtk.PrintDialog.setup`. .. versionadded:: 4.14 :param accept_label: the new accept label .. method:: set_modal(modal: bool) -> None Sets whether the print dialog blocks interaction with the parent window while it is presented. .. versionadded:: 4.14 :param modal: the new value .. method:: set_page_setup(page_setup: ~gi.repository.Gtk.PageSetup) -> None Set the page setup for the print dialog. .. versionadded:: 4.14 :param page_setup: the new page setup .. method:: set_print_settings(print_settings: ~gi.repository.Gtk.PrintSettings) -> None Sets the print settings for the print dialog. .. versionadded:: 4.14 :param print_settings: the new print settings .. method:: set_title(title: str) -> None Sets the title that will be shown on the print dialog. .. versionadded:: 4.14 :param title: the new title .. method:: setup(parent: ~gi.repository.Gtk.Window | None = None, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[...], None] | None = None, *user_data: ~typing.Any) -> None This function presents a print dialog to let the user select a printer, and set up print settings and page setup. The ``callback`` will be called when the dialog is dismissed. It should call :obj:`~gi.repository.Gtk.PrintDialog.setup_finish` to obtain the results in the form of a :obj:`~gi.repository.Gtk.PrintSetup`, that can then be passed to :obj:`~gi.repository.Gtk.PrintDialog.print` or :obj:`~gi.repository.Gtk.PrintDialog.print_file`. One possible use for this method is to have the user select a printer, then show a page setup UI in the application (e.g. to arrange images on a page), then call :obj:`~gi.repository.Gtk.PrintDialog.print` on ``self`` to do the printing without further user interaction. .. versionadded:: 4.14 :param parent: the parent ``GtkWindow`` :param cancellable: a ``GCancellable`` to cancel the operation :param callback: a callback to call when the operation is complete :param user_data: data to pass to ``callback`` .. method:: setup_finish(result: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.Gtk.PrintSetup | None Finishes the :obj:`~gi.repository.Gtk.PrintDialog.setup` call. If the call was successful, it returns a :obj:`~gi.repository.Gtk.PrintSetup` which contains the print settings and page setup information that will be used to print. .. versionadded:: 4.14 :param result: a ``GAsyncResult`` Properties ---------- .. rst-class:: interim-class .. class:: PrintDialog :no-index: .. attribute:: props.accept_label :type: str A label that may be shown on the accept button of a print dialog that is presented by :obj:`~gi.repository.Gtk.PrintDialog.setup`. .. versionadded:: 4.14 .. attribute:: props.modal :type: bool Whether the print dialog is modal. .. versionadded:: 4.14 .. attribute:: props.page_setup :type: ~gi.repository.Gtk.PageSetup The page setup to use. .. versionadded:: 4.14 .. attribute:: props.print_settings :type: ~gi.repository.Gtk.PrintSettings The print settings to use. .. versionadded:: 4.14 .. attribute:: props.title :type: str A title that may be shown on the print dialog that is presented by :obj:`~gi.repository.Gtk.PrintDialog.setup`. .. versionadded:: 4.14