:right-sidebar: True PaperSize =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: PaperSize(**kwargs) :no-contents-entry: ``GtkPaperSize`` handles paper sizes. It uses the standard called `PWG 5101.1-2002 PWG: Standard for Media Standardized Names `__ to name the paper sizes (and to get the data for the page sizes). In addition to standard paper sizes, ``GtkPaperSize`` allows to construct custom paper sizes with arbitrary dimensions. The ``GtkPaperSize`` object stores not only the dimensions (width and height) of a paper size and its name, it also provides default print margins. Constructors ------------ .. rst-class:: interim-class .. class:: PaperSize :no-index: .. classmethod:: new(name: str | None = None) -> ~gi.repository.Gtk.PaperSize Creates a new ``GtkPaperSize`` object by parsing a `PWG 5101.1-2002 `__ paper name. If ``name`` is :const:`None`, the default paper size is returned, see :obj:`~gi.repository.Gtk.PaperSize.get_default`\. :param name: a paper size name .. classmethod:: new_custom(name: str, display_name: str, width: float, height: float, unit: ~gi.repository.Gtk.Unit) -> ~gi.repository.Gtk.PaperSize Creates a new ``GtkPaperSize`` object with the given parameters. :param name: the paper name :param display_name: the human-readable name :param width: the paper width, in units of ``unit`` :param height: the paper height, in units of ``unit`` :param unit: the unit for ``width`` and ``height``\. not :const:`~gi.repository.Gtk.Unit.NONE`. .. classmethod:: new_from_gvariant(variant: ~gi.repository.GLib.Variant) -> ~gi.repository.Gtk.PaperSize Deserialize a paper size from a ``GVariant``\. The `GVariant must be in the format produced by :obj:`~gi.repository.Gtk.PaperSize.to_gvariant`\. :param variant: an a{sv} ``GVariant`` .. classmethod:: new_from_ipp(ipp_name: str, width: float, height: float) -> ~gi.repository.Gtk.PaperSize Creates a new ``GtkPaperSize`` object by using IPP information. If ``ipp_name`` is not a recognized paper name, ``width`` and ``height`` are used to construct a custom ``GtkPaperSize`` object. :param ipp_name: an IPP paper name :param width: the paper width, in points :param height: the paper height in points .. classmethod:: new_from_key_file(key_file: ~gi.repository.GLib.KeyFile, group_name: str | None = None) -> ~gi.repository.Gtk.PaperSize Reads a paper size from the group ``group_name`` in the key file ``key_file``\. :param key_file: the ``GKeyFile`` to retrieve the papersize from :param group_name: the name of the group in the key file to read, or :const:`None` to read the first group .. classmethod:: new_from_ppd(ppd_name: str, ppd_display_name: str, width: float, height: float) -> ~gi.repository.Gtk.PaperSize Creates a new ``GtkPaperSize`` object by using PPD information. If ``ppd_name`` is not a recognized PPD paper name, ``ppd_display_name``\, ``width`` and ``height`` are used to construct a custom ``GtkPaperSize`` object. :param ppd_name: a PPD paper name :param ppd_display_name: the corresponding human-readable name :param width: the paper width, in points :param height: the paper height in points Methods ------- .. rst-class:: interim-class .. class:: PaperSize :no-index: .. method:: free() -> None Free the given ``GtkPaperSize`` object. .. classmethod:: get_default() -> str Returns the name of the default paper size, which depends on the current locale. .. method:: get_default_bottom_margin(unit: ~gi.repository.Gtk.Unit) -> float Gets the default bottom margin for the ``GtkPaperSize``\. :param unit: the unit for the return value, not :const:`~gi.repository.Gtk.Unit.NONE` .. method:: get_default_left_margin(unit: ~gi.repository.Gtk.Unit) -> float Gets the default left margin for the ``GtkPaperSize``\. :param unit: the unit for the return value, not :const:`~gi.repository.Gtk.Unit.NONE` .. method:: get_default_right_margin(unit: ~gi.repository.Gtk.Unit) -> float Gets the default right margin for the ``GtkPaperSize``\. :param unit: the unit for the return value, not :const:`~gi.repository.Gtk.Unit.NONE` .. method:: get_default_top_margin(unit: ~gi.repository.Gtk.Unit) -> float Gets the default top margin for the ``GtkPaperSize``\. :param unit: the unit for the return value, not :const:`~gi.repository.Gtk.Unit.NONE` .. method:: get_display_name() -> str Gets the human-readable name of the ``GtkPaperSize``\. .. method:: get_height(unit: ~gi.repository.Gtk.Unit) -> float Gets the paper height of the ``GtkPaperSize``\, in units of ``unit``\. :param unit: the unit for the return value, not :const:`~gi.repository.Gtk.Unit.NONE` .. method:: get_name() -> str Gets the name of the ``GtkPaperSize``\. .. classmethod:: get_paper_sizes() -> list[~gi.repository.Gtk.PaperSize] Creates a list of known paper sizes. .. method:: get_ppd_name() -> str Gets the PPD name of the ``GtkPaperSize``\, which may be :const:`None`. .. method:: get_width(unit: ~gi.repository.Gtk.Unit) -> float Gets the paper width of the ``GtkPaperSize``\, in units of ``unit``\. :param unit: the unit for the return value, not :const:`~gi.repository.Gtk.Unit.NONE` .. method:: is_custom() -> bool Returns :const:`True` if ``size`` is not a standard paper size. .. method:: is_equal(size2: ~gi.repository.Gtk.PaperSize) -> bool Compares two ``GtkPaperSize`` objects. :param size2: another ``GtkPaperSize`` object .. method:: is_ipp() -> bool Returns :const:`True` if ``size`` is an IPP standard paper size. .. method:: set_size(width: float, height: float, unit: ~gi.repository.Gtk.Unit) -> None Changes the dimensions of a ``size`` to ``width`` x ``height``\. :param width: the new width in units of ``unit`` :param height: the new height in units of ``unit`` :param unit: the unit for ``width`` and ``height`` .. method:: to_gvariant() -> ~gi.repository.GLib.Variant Serialize a paper size to an ``a{sv}`` variant. .. method:: to_key_file(key_file: ~gi.repository.GLib.KeyFile, group_name: str) -> None This function adds the paper size from ``size`` to ``key_file``\. :param key_file: the ``GKeyFile`` to save the paper size to :param group_name: the group to add the settings to in ``key_file``