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
GtkPaperSize
object by parsing a PWG 5101.1-2002 paper name.If
name
isNone
, 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
GtkPaperSize
object with the given parameters.- Parameters:
name – the paper name
display_name – the human-readable name
width – the paper width, in units of
unit
height – the paper height, in units of
unit
unit – the unit for
width
andheight
. 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
GtkPaperSize
object by using IPP information.If
ipp_name
is not a recognized paper name,width
andheight
are used to construct a customGtkPaperSize
object.- 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_name
in the key filekey_file
.- Parameters:
key_file – the
GKeyFile
to retrieve the papersize fromgroup_name – the name of the group in the key file to read, or
None
to read the first group
- classmethod new_from_ppd(ppd_name: str, ppd_display_name: str, width: float, height: float) PaperSize #
Creates a new
GtkPaperSize
object by using PPD information.If
ppd_name
is not a recognized PPD paper name,ppd_display_name
,width
andheight
are used to construct a customGtkPaperSize
object.- 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
-
- 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_paper_sizes(include_custom: bool) list[PaperSize] #
Creates a list of known paper sizes.
- Parameters:
include_custom – whether to include custom paper sizes as defined in the page setup dialog
- 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
GtkPaperSize
objects.- Parameters:
size2 – another
GtkPaperSize
object