:right-sidebar: True PageSetup =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: PageSetup(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` A ``GtkPageSetup`` object stores the page size, orientation and margins. The idea is that you can get one of these from the page setup dialog and then pass it to the ``GtkPrintOperation`` when printing. The benefit of splitting this out of the ``GtkPrintSettings`` is that these affect the actual layout of the page, and thus need to be set long before user prints. Margins ------- The margins specified in this object are the “print margins”, i.e. the parts of the page that the printer cannot print on. These are different from the layout margins that a word processor uses; they are typically used to determine the minimal size for the layout margins. To obtain a ``GtkPageSetup`` use :obj:`~gi.repository.Gtk.PageSetup.new` to get the defaults, or use :obj:`~gi.repository.Gtk.print_run_page_setup_dialog` to show the page setup dialog and receive the resulting page setup. A page setup dialog ------------------- .. code-block:: :dedent: static GtkPrintSettings *settings = NULL; static GtkPageSetup *page_setup = NULL; static void do_page_setup (void) { GtkPageSetup *new_page_setup; if (settings == NULL) settings = gtk_print_settings_new (); new_page_setup = gtk_print_run_page_setup_dialog (GTK_WINDOW (main_window), page_setup, settings); if (page_setup) g_object_unref (page_setup); page_setup = new_page_setup; } Constructors ------------ .. rst-class:: interim-class .. class:: PageSetup :no-index: .. classmethod:: new() -> ~gi.repository.Gtk.PageSetup Creates a new ``GtkPageSetup``. .. classmethod:: new_from_file(file_name: str) -> ~gi.repository.Gtk.PageSetup Reads the page setup from the file ``file_name``. Returns a new ``GtkPageSetup`` object with the restored page setup, or :const:`None` if an error occurred. See :obj:`~gi.repository.Gtk.PageSetup.to_file`. :param file_name: the filename to read the page setup from .. classmethod:: new_from_gvariant(variant: ~gi.repository.GLib.Variant) -> ~gi.repository.Gtk.PageSetup Desrialize a page setup from an a{sv} variant. The variant must be in the format produced by :obj:`~gi.repository.Gtk.PageSetup.to_gvariant`. :param variant: an a{sv} ``GVariant`` .. classmethod:: new_from_key_file(key_file: ~gi.repository.GLib.KeyFile, group_name: str | None = None) -> ~gi.repository.Gtk.PageSetup Reads the page setup from the group ``group_name`` in the key file ``key_file``. Returns a new ``GtkPageSetup`` object with the restored page setup, or :const:`None` if an error occurred. :param key_file: the ``GKeyFile`` to retrieve the page_setup from :param group_name: the name of the group in the key_file to read to use the default name “Page Setup” Methods ------- .. rst-class:: interim-class .. class:: PageSetup :no-index: .. method:: get_bottom_margin(unit: ~gi.repository.Gtk.Unit) -> float Gets the bottom margin in units of ``unit``. :param unit: the unit for the return value .. method:: get_left_margin(unit: ~gi.repository.Gtk.Unit) -> float Gets the left margin in units of ``unit``. :param unit: the unit for the return value .. method:: get_orientation() -> ~gi.repository.Gtk.PageOrientation Gets the page orientation of the ``GtkPageSetup``. .. method:: get_page_height(unit: ~gi.repository.Gtk.Unit) -> float Returns the page height in units of ``unit``. Note that this function takes orientation and margins into consideration. See :obj:`~gi.repository.Gtk.PageSetup.get_paper_height`. :param unit: the unit for the return value .. method:: get_page_width(unit: ~gi.repository.Gtk.Unit) -> float Returns the page width in units of ``unit``. Note that this function takes orientation and margins into consideration. See :obj:`~gi.repository.Gtk.PageSetup.get_paper_width`. :param unit: the unit for the return value .. method:: get_paper_height(unit: ~gi.repository.Gtk.Unit) -> float Returns the paper height in units of ``unit``. Note that this function takes orientation, but not margins into consideration. See :obj:`~gi.repository.Gtk.PageSetup.get_page_height`. :param unit: the unit for the return value .. method:: get_paper_size() -> ~gi.repository.Gtk.PaperSize Gets the paper size of the ``GtkPageSetup``. .. method:: get_paper_width(unit: ~gi.repository.Gtk.Unit) -> float Returns the paper width in units of ``unit``. Note that this function takes orientation, but not margins into consideration. See :obj:`~gi.repository.Gtk.PageSetup.get_page_width`. :param unit: the unit for the return value .. method:: get_right_margin(unit: ~gi.repository.Gtk.Unit) -> float Gets the right margin in units of ``unit``. :param unit: the unit for the return value .. method:: get_top_margin(unit: ~gi.repository.Gtk.Unit) -> float Gets the top margin in units of ``unit``. :param unit: the unit for the return value .. method:: load_file(file_name: str) -> bool Reads the page setup from the file ``file_name``. See :obj:`~gi.repository.Gtk.PageSetup.to_file`. :param file_name: the filename to read the page setup from .. method:: load_key_file(key_file: ~gi.repository.GLib.KeyFile, group_name: str | None = None) -> bool Reads the page setup from the group ``group_name`` in the key file ``key_file``. :param key_file: the ``GKeyFile`` to retrieve the page_setup from :param group_name: the name of the group in the key_file to read to use the default name “Page Setup” .. method:: set_bottom_margin(margin: float, unit: ~gi.repository.Gtk.Unit) -> None Sets the bottom margin of the ``GtkPageSetup``. :param margin: the new bottom margin in units of ``unit`` :param unit: the units for ``margin`` .. method:: set_left_margin(margin: float, unit: ~gi.repository.Gtk.Unit) -> None Sets the left margin of the ``GtkPageSetup``. :param margin: the new left margin in units of ``unit`` :param unit: the units for ``margin`` .. method:: set_orientation(orientation: ~gi.repository.Gtk.PageOrientation) -> None Sets the page orientation of the ``GtkPageSetup``. :param orientation: a ``GtkPageOrientation`` value .. method:: set_paper_size(size: ~gi.repository.Gtk.PaperSize) -> None Sets the paper size of the ``GtkPageSetup`` without changing the margins. See :obj:`~gi.repository.Gtk.PageSetup.set_paper_size_and_default_margins`. :param size: a ``GtkPaperSize`` .. method:: set_paper_size_and_default_margins(size: ~gi.repository.Gtk.PaperSize) -> None Sets the paper size of the ``GtkPageSetup`` and modifies the margins according to the new paper size. :param size: a ``GtkPaperSize`` .. method:: set_right_margin(margin: float, unit: ~gi.repository.Gtk.Unit) -> None Sets the right margin of the ``GtkPageSetup``. :param margin: the new right margin in units of ``unit`` :param unit: the units for ``margin`` .. method:: set_top_margin(margin: float, unit: ~gi.repository.Gtk.Unit) -> None Sets the top margin of the ``GtkPageSetup``. :param margin: the new top margin in units of ``unit`` :param unit: the units for ``margin`` .. method:: to_file(file_name: str) -> bool This function saves the information from ``setup`` to ``file_name``. :param file_name: the file to save to .. method:: to_gvariant() -> ~gi.repository.GLib.Variant Serialize page setup to an a{sv} variant. .. method:: to_key_file(key_file: ~gi.repository.GLib.KeyFile, group_name: str | None = None) -> None This function adds the page setup from ``setup`` to ``key_file``. :param key_file: the ``GKeyFile`` to save the page setup to :param group_name: the group to add the settings to in ``key_file``, or :const:`None` to use the default name “Page Setup”