PaperSize#
- class PaperSize(**kwargs)#
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#
- class PaperSize
- classmethod new(name: str | None = None) PaperSize#
Creates a new
GtkPaperSizeobject by parsing a PWG 5101.1-2002 paper name.If
nameisNone, the default paper size is returned, seeget_default.- Parameters:
name – a paper size name
- classmethod new_custom(name: str, display_name: str, width: float, height: float, unit: Unit) PaperSize#
Creates a new
GtkPaperSizeobject with the given parameters.- Parameters:
name – the paper name
display_name – the human-readable name
width – the paper width, in units of
unitheight – the paper height, in units of
unitunit – the unit for
widthandheight. notNONE.
- classmethod new_from_gvariant(variant: Variant) PaperSize#
Deserialize a paper size from a
GVariant.The
GVariant must be in the format produced by :obj:`~gi.repository.Gtk.PaperSize.to_gvariant.- Parameters:
variant – an a{sv}
GVariant
- classmethod new_from_ipp(ipp_name: str, width: float, height: float) PaperSize#
Creates a new
GtkPaperSizeobject by using IPP information.If
ipp_nameis not a recognized paper name,widthandheightare used to construct a customGtkPaperSizeobject.- Parameters:
ipp_name – an IPP paper name
width – the paper width, in points
height – the paper height in points
- classmethod new_from_key_file(key_file: KeyFile, group_name: str | None = None) PaperSize#
Reads a paper size from the group
group_namein the key filekey_file.- Parameters:
key_file – the
GKeyFileto retrieve the papersize fromgroup_name – the name of the group in the key file to read, or
Noneto read the first group
- classmethod new_from_ppd(ppd_name: str, ppd_display_name: str, width: float, height: float) PaperSize#
Creates a new
GtkPaperSizeobject by using PPD information.If
ppd_nameis not a recognized PPD paper name,ppd_display_name,widthandheightare used to construct a customGtkPaperSizeobject.- Parameters:
ppd_name – a PPD paper name
ppd_display_name – the corresponding human-readable name
width – the paper width, in points
height – the paper height in points
Methods#
- class PaperSize
-
- classmethod get_default() str#
Returns the name of the default paper size, which depends on the current locale.
- get_default_bottom_margin(unit: Unit) float#
Gets the default bottom margin for the
GtkPaperSize.- Parameters:
unit – the unit for the return value, not
NONE
- get_default_left_margin(unit: Unit) float#
Gets the default left margin for the
GtkPaperSize.- Parameters:
unit – the unit for the return value, not
NONE
- get_default_right_margin(unit: Unit) float#
Gets the default right margin for the
GtkPaperSize.- Parameters:
unit – the unit for the return value, not
NONE
- get_default_top_margin(unit: Unit) float#
Gets the default top margin for the
GtkPaperSize.- Parameters:
unit – the unit for the return value, not
NONE
- get_height(unit: Unit) float#
Gets the paper height of the
GtkPaperSize, in units ofunit.- Parameters:
unit – the unit for the return value, not
NONE
- get_width(unit: Unit) float#
Gets the paper width of the
GtkPaperSize, in units ofunit.- Parameters:
unit – the unit for the return value, not
NONE
- is_equal(size2: PaperSize) bool#
Compares two
GtkPaperSizeobjects.- Parameters:
size2 – another
GtkPaperSizeobject