Gtk.PaperSize

Fields

None

Methods

class

get_default ()

class

get_paper_sizes (include_custom)

class

new (name)

class

new_custom (name, display_name, width, height, unit)

class

new_from_gvariant (variant)

class

new_from_ipp (ipp_name, width, height)

class

new_from_key_file (key_file, group_name)

class

new_from_ppd (ppd_name, ppd_display_name, width, height)

copy ()

free ()

get_default_bottom_margin (unit)

get_default_left_margin (unit)

get_default_right_margin (unit)

get_default_top_margin (unit)

get_display_name ()

get_height (unit)

get_name ()

get_ppd_name ()

get_width (unit)

is_custom ()

is_equal (size2)

is_ipp ()

set_size (width, height, unit)

to_gvariant ()

to_key_file (key_file, group_name)

Details

class Gtk.PaperSize

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.

classmethod get_default()[source]
Returns:

the name of the default paper size. The string is owned by GTK and should not be modified.

Return type:

str

Returns the name of the default paper size, which depends on the current locale.

classmethod get_paper_sizes(include_custom)[source]
Parameters:

include_custom (bool) – whether to include custom paper sizes as defined in the page setup dialog

Returns:

a newly allocated list of newly allocated GtkPaperSize objects

Return type:

[Gtk.PaperSize]

Creates a list of known paper sizes.

classmethod new(name)[source]
Parameters:

name (str or None) – a paper size name

Returns:

a new GtkPaperSize, use [method`Gtk`.PaperSize.free] to free it

Return type:

Gtk.PaperSize

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 [func`Gtk`.PaperSize.get_default].

classmethod new_custom(name, display_name, width, height, unit)[source]
Parameters:
  • name (str) – the paper name

  • display_name (str) – the human-readable name

  • width (float) – the paper width, in units of unit

  • height (float) – the paper height, in units of unit

  • unit (Gtk.Unit) – the unit for width and height. not Gtk.Unit.NONE.

Returns:

a new GtkPaperSize object, use [method`Gtk`.PaperSize.free] to free it

Return type:

Gtk.PaperSize

Creates a new GtkPaperSize object with the given parameters.

classmethod new_from_gvariant(variant)[source]
Parameters:

variant (GLib.Variant) – an a{sv} GVariant

Returns:

a new GtkPaperSize object

Return type:

Gtk.PaperSize

Deserialize a paper size from a GVariant.

The `:obj:GLib.Variant must be in the format produced by [method`Gtk`.PaperSize.to_gvariant].

classmethod new_from_ipp(ipp_name, width, height)[source]
Parameters:
  • ipp_name (str) – an IPP paper name

  • width (float) – the paper width, in points

  • height (float) – the paper height in points

Returns:

a new GtkPaperSize, use [method`Gtk`.PaperSize.free] to free it

Return type:

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.

classmethod new_from_key_file(key_file, group_name)[source]
Parameters:
  • key_file (GLib.KeyFile) – the GKeyFile to retrieve the papersize from

  • group_name (str or None) – the name of the group in the key file to read, or None to read the first group

Raises:

GLib.Error

Returns:

a new GtkPaperSize object with the restored paper size

Return type:

Gtk.PaperSize

Reads a paper size from the group group_name in the key file key_file.

classmethod new_from_ppd(ppd_name, ppd_display_name, width, height)[source]
Parameters:
  • ppd_name (str) – a PPD paper name

  • ppd_display_name (str) – the corresponding human-readable name

  • width (float) – the paper width, in points

  • height (float) – the paper height in points

Returns:

a new GtkPaperSize, use [method`Gtk`.PaperSize.free] to free it

Return type:

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.

copy()[source]
Returns:

a copy of self

Return type:

Gtk.PaperSize

Copies an existing GtkPaperSize.

free()[source]

Free the given GtkPaperSize object.

get_default_bottom_margin(unit)[source]
Parameters:

unit (Gtk.Unit) – the unit for the return value, not Gtk.Unit.NONE

Returns:

the default bottom margin

Return type:

float

Gets the default bottom margin for the GtkPaperSize.

get_default_left_margin(unit)[source]
Parameters:

unit (Gtk.Unit) – the unit for the return value, not Gtk.Unit.NONE

Returns:

the default left margin

Return type:

float

Gets the default left margin for the GtkPaperSize.

get_default_right_margin(unit)[source]
Parameters:

unit (Gtk.Unit) – the unit for the return value, not Gtk.Unit.NONE

Returns:

the default right margin

Return type:

float

Gets the default right margin for the GtkPaperSize.

get_default_top_margin(unit)[source]
Parameters:

unit (Gtk.Unit) – the unit for the return value, not Gtk.Unit.NONE

Returns:

the default top margin

Return type:

float

Gets the default top margin for the GtkPaperSize.

get_display_name()[source]
Returns:

the human-readable name of self

Return type:

str

Gets the human-readable name of the GtkPaperSize.

get_height(unit)[source]
Parameters:

unit (Gtk.Unit) – the unit for the return value, not Gtk.Unit.NONE

Returns:

the paper height

Return type:

float

Gets the paper height of the GtkPaperSize, in units of unit.

get_name()[source]
Returns:

the name of self

Return type:

str

Gets the name of the GtkPaperSize.

get_ppd_name()[source]
Returns:

the PPD name of self

Return type:

str

Gets the PPD name of the GtkPaperSize, which may be None.

get_width(unit)[source]
Parameters:

unit (Gtk.Unit) – the unit for the return value, not Gtk.Unit.NONE

Returns:

the paper width

Return type:

float

Gets the paper width of the GtkPaperSize, in units of unit.

is_custom()[source]
Returns:

whether self is a custom paper size.

Return type:

bool

Returns True if self is not a standard paper size.

is_equal(size2)[source]
Parameters:

size2 (Gtk.PaperSize) – another GtkPaperSize object

Returns:

True, if self and size2 represent the same paper size

Return type:

bool

Compares two GtkPaperSize objects.

is_ipp()[source]
Returns:

whether self is not an IPP custom paper size.

Return type:

bool

Returns True if self is an IPP standard paper size.

set_size(width, height, unit)[source]
Parameters:
  • width (float) – the new width in units of unit

  • height (float) – the new height in units of unit

  • unit (Gtk.Unit) – the unit for width and height

Changes the dimensions of a self to width x height.

to_gvariant()[source]
Returns:

a new, floating, GVariant

Return type:

GLib.Variant

Serialize a paper size to an a{sv} variant.

to_key_file(key_file, group_name)[source]
Parameters:
  • key_file (GLib.KeyFile) – the GKeyFile to save the paper size to

  • group_name (str) – the group to add the settings to in key_file

This function adds the paper size from self to key_file.