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

Gtk.PaperSize 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, Gtk.PaperSize allows to construct custom paper sizes with arbitrary dimensions.

The Gtk.PaperSize object stores not only the dimensions (width and height) of a paper size and its name, it also provides default print margins.

Printing support has been added in GTK+ 2.10.

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.

New in version 2.10.

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 Gtk.PaperSize objects

Return type:

[Gtk.PaperSize]

Creates a list of known paper sizes.

New in version 2.12.

classmethod new(name)[source]
Parameters:

name (str or None) – a paper size name, or None

Returns:

a new Gtk.PaperSize, use Gtk.PaperSize.free() to free it

Return type:

Gtk.PaperSize

Creates a new Gtk.PaperSize object by parsing a PWG 5101.1-2002 paper name.

If name is None, the default paper size is returned, see Gtk.PaperSize.get_default().

New in version 2.10.

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 Gtk.PaperSize object, use Gtk.PaperSize.free() to free it

Return type:

Gtk.PaperSize

Creates a new Gtk.PaperSize object with the given parameters.

New in version 2.10.

classmethod new_from_gvariant(variant)[source]
Parameters:

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

Returns:

a new Gtk.PaperSize object

Return type:

Gtk.PaperSize

Deserialize a paper size from an a{sv} variant in the format produced by Gtk.PaperSize.to_gvariant().

New in version 3.22.

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 Gtk.PaperSize, use Gtk.PaperSize.free() to free it

Return type:

Gtk.PaperSize

Creates a new Gtk.PaperSize object by using IPP information.

If ipp_name is not a recognized paper name, width and height are used to construct a custom Gtk.PaperSize object.

New in version 3.16.

classmethod new_from_key_file(key_file, group_name)[source]
Parameters:
  • key_file (GLib.KeyFile) – the GLib.KeyFile 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 Gtk.PaperSize object with the restored paper size, or None if an error occurred

Return type:

Gtk.PaperSize

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

New in version 2.12.

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 Gtk.PaperSize, use Gtk.PaperSize.free() to free it

Return type:

Gtk.PaperSize

Creates a new Gtk.PaperSize 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 Gtk.PaperSize object.

New in version 2.10.

copy()[source]
Returns:

a copy of self

Return type:

Gtk.PaperSize

Copies an existing Gtk.PaperSize.

New in version 2.10.

free()[source]

Free the given Gtk.PaperSize object.

New in version 2.10.

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 Gtk.PaperSize.

New in version 2.10.

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 Gtk.PaperSize.

New in version 2.10.

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 Gtk.PaperSize.

New in version 2.10.

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 Gtk.PaperSize.

New in version 2.10.

get_display_name()[source]
Returns:

the human-readable name of self

Return type:

str

Gets the human-readable name of the Gtk.PaperSize.

New in version 2.10.

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 Gtk.PaperSize, in units of unit.

New in version 2.10.

get_name()[source]
Returns:

the name of self

Return type:

str

Gets the name of the Gtk.PaperSize.

New in version 2.10.

get_ppd_name()[source]
Returns:

the PPD name of self

Return type:

str

Gets the PPD name of the Gtk.PaperSize, which may be None.

New in version 2.10.

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 Gtk.PaperSize, in units of unit.

New in version 2.10.

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 Gtk.PaperSize object

Returns:

True, if self and size2 represent the same paper size

Return type:

bool

Compares two Gtk.PaperSize objects.

New in version 2.10.

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.

New in version 2.10.

to_gvariant()[source]
Returns:

a new, floating, GLib.Variant

Return type:

GLib.Variant

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

New in version 3.22.

to_key_file(key_file, group_name)[source]
Parameters:
  • key_file (GLib.KeyFile) – the GLib.KeyFile 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.

New in version 2.12.