Gtk.PaperSize¶
record (struct)
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¶
new¶
Creates a new GtkPaperSize object by parsing a
PWG 5101.1-2002
paper name.
If name is None, the default paper size is returned,
see PaperSize.get_default.
Parameters:
name— a paper size name
new_custom¶
@classmethod
def new_custom(cls, name: str, display_name: str, width: float, height: float, unit: Unit | int) -> PaperSize
Creates a new GtkPaperSize object with the
given parameters.
Parameters:
name— the paper namedisplay_name— the human-readable namewidth— the paper width, in units ofunitheight— the paper height, in units ofunitunit— the unit forwidthandheight. notUnit.NONE.
new_from_gvariant¶
Deserialize a paper size from a GVariant.
The GVariant must be in the format produced by
[PaperSize.to_gvariant`](./PaperSize.md#method-to_gvariant).
Parameters:
variant— an a{sv}GVariant
new_from_ipp¶
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.
Parameters:
ipp_name— an IPP paper namewidth— the paper width, in pointsheight— the paper height in points
new_from_key_file¶
@classmethod
def new_from_key_file(cls, key_file: GLib.KeyFile, group_name: str | None = ...) -> PaperSize
Reads a paper size from the group group_name in the key file
key_file.
Parameters:
key_file— theGKeyFileto retrieve the papersize fromgroup_name— the name of the group in the key file to read, orNoneto read the first group
new_from_ppd¶
@classmethod
def new_from_ppd(cls, 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 and height are used to
construct a custom GtkPaperSize object.
Parameters:
ppd_name— a PPD paper nameppd_display_name— the corresponding human-readable namewidth— the paper width, in pointsheight— the paper height in points
Methods¶
copy¶
Copies an existing GtkPaperSize.
free¶
Free the given GtkPaperSize object.
get_default_bottom_margin¶
Gets the default bottom margin for the GtkPaperSize.
Parameters:
unit— the unit for the return value, notUnit.NONE
get_default_left_margin¶
Gets the default left margin for the GtkPaperSize.
Parameters:
unit— the unit for the return value, notUnit.NONE
get_default_right_margin¶
Gets the default right margin for the GtkPaperSize.
Parameters:
unit— the unit for the return value, notUnit.NONE
get_default_top_margin¶
Gets the default top margin for the GtkPaperSize.
Parameters:
unit— the unit for the return value, notUnit.NONE
get_display_name¶
Gets the human-readable name of the GtkPaperSize.
get_height¶
Gets the paper height of the GtkPaperSize, in
units of unit.
Parameters:
unit— the unit for the return value, notUnit.NONE
get_name¶
Gets the name of the GtkPaperSize.
get_ppd_name¶
Gets the PPD name of the GtkPaperSize, which
may be None.
get_width¶
Gets the paper width of the GtkPaperSize, in
units of unit.
Parameters:
unit— the unit for the return value, notUnit.NONE
is_custom¶
Returns True if size is not a standard paper size.
is_equal¶
Compares two GtkPaperSize objects.
Parameters:
size2— anotherGtkPaperSizeobject
is_ipp¶
Returns True if size is an IPP standard paper size.
set_size¶
Changes the dimensions of a size to width x height.
Parameters:
width— the new width in units ofunitheight— the new height in units ofunitunit— the unit forwidthandheight
to_gvariant¶
Serialize a paper size to an a{sv} variant.
to_key_file¶
This function adds the paper size from size to key_file.
Parameters:
key_file— theGKeyFileto save the paper size togroup_name— the group to add the settings to inkey_file
Static functions¶
get_default¶
Returns the name of the default paper size, which depends on the current locale.
get_paper_sizes¶
Creates a list of known paper sizes.
Parameters:
include_custom— whether to include custom paper sizes as defined in the page setup dialog