Gtk.PageSetup¶
class — extends GObject.Object
Stores page size, orientation and margins for printing.
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 PageSetup.new to get the defaults,
or use print_run_page_setup_dialog to show the page setup dialog
and receive the resulting page setup.
A page setup dialog¶
static GtkPrintSettings *settings = NULL;
static GtkPageSetup *page_setup = NULL;
static void
do_page_setup (void)
{
GtkPageSetup *new_page_setup;
if (settings == NULL)
settings = gtk_print_settings_new ();
new_page_setup = gtk_print_run_page_setup_dialog (GTK_WINDOW (main_window),
page_setup, settings);
if (page_setup)
g_object_unref (page_setup);
page_setup = new_page_setup;
}
Constructors¶
new¶
Creates a new GtkPageSetup.
new_from_file¶
@classmethod
def new_from_file(cls, file_name: str | bytes | os.PathLike[str] | os.PathLike[bytes]) -> 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 PageSetup.to_file.
Parameters:
file_name— the filename to read the page setup from
new_from_gvariant¶
Desrialize a page setup from an a{sv} variant.
The variant must be in the format produced by
PageSetup.to_gvariant.
Parameters:
variant— an a{sv}GVariant
new_from_key_file¶
@classmethod
def new_from_key_file(cls, key_file: GLib.KeyFile, group_name: str | None = ...) -> 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.
Parameters:
key_file— theGKeyFileto retrieve the page_setup fromgroup_name— the name of the group in the key_file to read to use the default name “Page Setup”
Methods¶
copy¶
Copies a GtkPageSetup.
get_bottom_margin¶
Gets the bottom margin in units of unit.
Parameters:
unit— the unit for the return value
get_left_margin¶
Gets the left margin in units of unit.
Parameters:
unit— the unit for the return value
get_orientation¶
Gets the page orientation of the GtkPageSetup.
get_page_height¶
Returns the page height in units of unit.
Note that this function takes orientation
and margins into consideration.
See PageSetup.get_paper_height.
Parameters:
unit— the unit for the return value
get_page_width¶
Returns the page width in units of unit.
Note that this function takes orientation
and margins into consideration.
See PageSetup.get_paper_width.
Parameters:
unit— the unit for the return value
get_paper_height¶
Returns the paper height in units of unit.
Note that this function takes orientation,
but not margins into consideration.
See PageSetup.get_page_height.
Parameters:
unit— the unit for the return value
get_paper_size¶
Gets the paper size of the GtkPageSetup.
get_paper_width¶
Returns the paper width in units of unit.
Note that this function takes orientation,
but not margins into consideration.
See PageSetup.get_page_width.
Parameters:
unit— the unit for the return value
get_right_margin¶
Gets the right margin in units of unit.
Parameters:
unit— the unit for the return value
get_top_margin¶
Gets the top margin in units of unit.
Parameters:
unit— the unit for the return value
load_file¶
Reads the page setup from the file file_name.
See PageSetup.to_file.
Parameters:
file_name— the filename to read the page setup from
load_key_file¶
Reads the page setup from the group group_name in the key file
key_file.
Parameters:
key_file— theGKeyFileto retrieve the page_setup fromgroup_name— the name of the group in the key_file to read to use the default name “Page Setup”
set_bottom_margin¶
Sets the bottom margin of the GtkPageSetup.
Parameters:
margin— the new bottom margin in units ofunitunit— the units formargin
set_left_margin¶
Sets the left margin of the GtkPageSetup.
Parameters:
margin— the new left margin in units ofunitunit— the units formargin
set_orientation¶
Sets the page orientation of the GtkPageSetup.
Parameters:
orientation— aGtkPageOrientationvalue
set_paper_size¶
Sets the paper size of the GtkPageSetup without
changing the margins.
See PageSetup.set_paper_size_and_default_margins.
Parameters:
size— aGtkPaperSize
set_paper_size_and_default_margins¶
Sets the paper size of the GtkPageSetup and modifies
the margins according to the new paper size.
Parameters:
size— aGtkPaperSize
set_right_margin¶
Sets the right margin of the GtkPageSetup.
Parameters:
margin— the new right margin in units ofunitunit— the units formargin
set_top_margin¶
Sets the top margin of the GtkPageSetup.
Parameters:
margin— the new top margin in units ofunitunit— the units formargin
to_file¶
This function saves the information from setup to file_name.
Parameters:
file_name— the file to save to
to_gvariant¶
Serialize page setup to an a{sv} variant.
to_key_file¶
This function adds the page setup from setup to key_file.
Parameters:
key_file— theGKeyFileto save the page setup togroup_name— the group to add the settings to inkey_file, orNoneto use the default name “Page Setup”