Gtk.PageSetup

g GObject.Object GObject.Object Gtk.PageSetup Gtk.PageSetup GObject.Object->Gtk.PageSetup

Example

../_images/PageSetup.png
Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

class

new_from_file (file_name)

class

new_from_gvariant (variant)

class

new_from_key_file (key_file, group_name)

copy ()

get_bottom_margin (unit)

get_left_margin (unit)

get_orientation ()

get_page_height (unit)

get_page_width (unit)

get_paper_height (unit)

get_paper_size ()

get_paper_width (unit)

get_right_margin (unit)

get_top_margin (unit)

load_file (file_name)

load_key_file (key_file, group_name)

set_bottom_margin (margin, unit)

set_left_margin (margin, unit)

set_orientation (orientation)

set_paper_size (size)

set_paper_size_and_default_margins (size)

set_right_margin (margin, unit)

set_top_margin (margin, unit)

to_file (file_name)

to_gvariant ()

to_key_file (key_file, group_name)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class Gtk.PageSetup(**kwargs)
Bases:

GObject.Object

Abstract:

No

A GtkPageSetup object stores the page size, orientation and margins.

The idea is that you can get one of these from the page setup dialog and then pass it to the GtkPrintOperation when printing. The benefit of splitting this out of the GtkPrintSettings is that these affect the actual layout of the page, and thus need to be set long before user prints.

Margins

The margins specified in this object are the “print margins”, i.e. the parts of the page that the printer cannot print on. These are different from the layout margins that a word processor uses; they are typically used to determine the minimal size for the layout margins.

To obtain a GtkPageSetup use [ctor`Gtk`.PageSetup.new] to get the defaults, or use [func`Gtk`.print_run_page_setup_dialog] to show the page setup dialog and receive the resulting page setup.

A page setup dialog

```c static Gtk.PrintSettings *settings = None; static Gtk.PageSetup *page_setup = None;

static void do_page_setup (void) { Gtk.PageSetup *new_page_setup;

if (settings == None) settings = Gtk.PrintSettings.new ();

new_page_setup = Gtk.print_run_page_setup_dialog (GTK_WINDOW (main_window), page_setup, settings);

if (page_setup) GObject.Object.unref (page_setup);

page_setup = new_page_setup; } ```

classmethod new()[source]
Returns:

a new GtkPageSetup.

Return type:

Gtk.PageSetup

Creates a new GtkPageSetup.

classmethod new_from_file(file_name)[source]
Parameters:

file_name (str) – the filename to read the page setup from

Raises:

GLib.Error

Returns:

the restored GtkPageSetup

Return type:

Gtk.PageSetup

Reads the page setup from the file file_name.

Returns a new GtkPageSetup object with the restored page setup, or None if an error occurred. See [method`Gtk`.PageSetup.to_file].

classmethod new_from_gvariant(variant)[source]
Parameters:

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

Returns:

a new GtkPageSetup object

Return type:

Gtk.PageSetup

Desrialize a page setup from an a{sv} variant.

The variant must be in the format produced by [method`Gtk`.PageSetup.to_gvariant].

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

  • group_name (str or None) – the name of the group in the key_file to read to use the default name “Page Setup”

Raises:

GLib.Error

Returns:

the restored GtkPageSetup

Return type:

Gtk.PageSetup

Reads the page setup from the group group_name in the key file key_file.

Returns a new GtkPageSetup object with the restored page setup, or None if an error occurred.

copy()[source]
Returns:

a copy of self

Return type:

Gtk.PageSetup

Copies a GtkPageSetup.

get_bottom_margin(unit)[source]
Parameters:

unit (Gtk.Unit) – the unit for the return value

Returns:

the bottom margin

Return type:

float

Gets the bottom margin in units of unit.

get_left_margin(unit)[source]
Parameters:

unit (Gtk.Unit) – the unit for the return value

Returns:

the left margin

Return type:

float

Gets the left margin in units of unit.

get_orientation()[source]
Returns:

the page orientation

Return type:

Gtk.PageOrientation

Gets the page orientation of the GtkPageSetup.

get_page_height(unit)[source]
Parameters:

unit (Gtk.Unit) – the unit for the return value

Returns:

the page height.

Return type:

float

Returns the page height in units of unit.

Note that this function takes orientation and margins into consideration. See [method`Gtk`.PageSetup.get_paper_height].

get_page_width(unit)[source]
Parameters:

unit (Gtk.Unit) – the unit for the return value

Returns:

the page width.

Return type:

float

Returns the page width in units of unit.

Note that this function takes orientation and margins into consideration. See [method`Gtk`.PageSetup.get_paper_width].

get_paper_height(unit)[source]
Parameters:

unit (Gtk.Unit) – the unit for the return value

Returns:

the paper height.

Return type:

float

Returns the paper height in units of unit.

Note that this function takes orientation, but not margins into consideration. See [method`Gtk`.PageSetup.get_page_height].

get_paper_size()[source]
Returns:

the paper size

Return type:

Gtk.PaperSize

Gets the paper size of the GtkPageSetup.

get_paper_width(unit)[source]
Parameters:

unit (Gtk.Unit) – the unit for the return value

Returns:

the paper width.

Return type:

float

Returns the paper width in units of unit.

Note that this function takes orientation, but not margins into consideration. See [method`Gtk`.PageSetup.get_page_width].

get_right_margin(unit)[source]
Parameters:

unit (Gtk.Unit) – the unit for the return value

Returns:

the right margin

Return type:

float

Gets the right margin in units of unit.

get_top_margin(unit)[source]
Parameters:

unit (Gtk.Unit) – the unit for the return value

Returns:

the top margin

Return type:

float

Gets the top margin in units of unit.

load_file(file_name)[source]
Parameters:

file_name (str) – the filename to read the page setup from

Raises:

GLib.Error

Returns:

True on success

Return type:

bool

Reads the page setup from the file file_name.

See [method`Gtk`.PageSetup.to_file].

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

  • group_name (str or None) – the name of the group in the key_file to read to use the default name “Page Setup”

Raises:

GLib.Error

Returns:

True on success

Return type:

bool

Reads the page setup from the group group_name in the key file key_file.

set_bottom_margin(margin, unit)[source]
Parameters:
  • margin (float) – the new bottom margin in units of unit

  • unit (Gtk.Unit) – the units for margin

Sets the bottom margin of the GtkPageSetup.

set_left_margin(margin, unit)[source]
Parameters:
  • margin (float) – the new left margin in units of unit

  • unit (Gtk.Unit) – the units for margin

Sets the left margin of the GtkPageSetup.

set_orientation(orientation)[source]
Parameters:

orientation (Gtk.PageOrientation) – a GtkPageOrientation value

Sets the page orientation of the GtkPageSetup.

set_paper_size(size)[source]
Parameters:

size (Gtk.PaperSize) – a GtkPaperSize

Sets the paper size of the GtkPageSetup without changing the margins.

See [method`Gtk`.PageSetup.set_paper_size_and_default_margins].

set_paper_size_and_default_margins(size)[source]
Parameters:

size (Gtk.PaperSize) – a GtkPaperSize

Sets the paper size of the GtkPageSetup and modifies the margins according to the new paper size.

set_right_margin(margin, unit)[source]
Parameters:
  • margin (float) – the new right margin in units of unit

  • unit (Gtk.Unit) – the units for margin

Sets the right margin of the GtkPageSetup.

set_top_margin(margin, unit)[source]
Parameters:
  • margin (float) – the new top margin in units of unit

  • unit (Gtk.Unit) – the units for margin

Sets the top margin of the GtkPageSetup.

to_file(file_name)[source]
Parameters:

file_name (str) – the file to save to

Raises:

GLib.Error

Returns:

True on success

Return type:

bool

This function saves the information from self to file_name.

to_gvariant()[source]
Returns:

a new, floating, GVariant

Return type:

GLib.Variant

Serialize page setup to an a{sv} variant.

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

  • group_name (str or None) – the group to add the settings to in key_file, or None to use the default name “Page Setup”

This function adds the page setup from self to key_file.