Gtk.PrintSettings

g GObject.Object GObject.Object Gtk.PrintSettings Gtk.PrintSettings GObject.Object->Gtk.PrintSettings

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 ()

foreach (func, *user_data)

get (key)

get_bool (key)

get_collate ()

get_default_source ()

get_dither ()

get_double (key)

get_double_with_default (key, def_)

get_duplex ()

get_finishings ()

get_int (key)

get_int_with_default (key, def_)

get_length (key, unit)

get_media_type ()

get_n_copies ()

get_number_up ()

get_number_up_layout ()

get_orientation ()

get_output_bin ()

get_page_ranges ()

get_page_set ()

get_paper_height (unit)

get_paper_size ()

get_paper_width (unit)

get_print_pages ()

get_printer ()

get_printer_lpi ()

get_quality ()

get_resolution ()

get_resolution_x ()

get_resolution_y ()

get_reverse ()

get_scale ()

get_use_color ()

has_key (key)

load_file (file_name)

load_key_file (key_file, group_name)

set (key, value)

set_bool (key, value)

set_collate (collate)

set_default_source (default_source)

set_dither (dither)

set_double (key, value)

set_duplex (duplex)

set_finishings (finishings)

set_int (key, value)

set_length (key, value, unit)

set_media_type (media_type)

set_n_copies (num_copies)

set_number_up (number_up)

set_number_up_layout (number_up_layout)

set_orientation (orientation)

set_output_bin (output_bin)

set_page_ranges (page_ranges)

set_page_set (page_set)

set_paper_height (height, unit)

set_paper_size (paper_size)

set_paper_width (width, unit)

set_print_pages (pages)

set_printer (printer)

set_printer_lpi (lpi)

set_quality (quality)

set_resolution (resolution)

set_resolution_xy (resolution_x, resolution_y)

set_reverse (reverse)

set_scale (scale)

set_use_color (use_color)

to_file (file_name)

to_gvariant ()

to_key_file (key_file, group_name)

unset (key)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class Gtk.PrintSettings(**kwargs)
Bases:

GObject.Object

Abstract:

No

A GtkPrintSettings object represents the settings of a print dialog in a system-independent way.

The main use for this object is that once you’ve printed you can get a settings object that represents the settings the user chose, and the next time you print you can pass that object in so that the user doesn’t have to re-set all his settings.

Its also possible to enumerate the settings so that you can easily save the settings for the next time your app runs, or even store them in a document. The predefined keys try to use shared values as much as possible so that moving such a document between systems still works.

classmethod new()[source]
Returns:

a new GtkPrintSettings object

Return type:

Gtk.PrintSettings

Creates a new GtkPrintSettings object.

classmethod new_from_file(file_name)[source]
Parameters:

file_name (str) – the filename to read the settings from

Raises:

GLib.Error

Returns:

the restored GtkPrintSettings

Return type:

Gtk.PrintSettings

Reads the print settings from file_name.

Returns a new GtkPrintSettings object with the restored settings, or None if an error occurred. If the file could not be loaded then error is set to either a GFileError or GKeyFileError.

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

classmethod new_from_gvariant(variant)[source]
Parameters:

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

Returns:

a new GtkPrintSettings object

Return type:

Gtk.PrintSettings

Deserialize print settings from an a{sv} variant.

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

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

  • group_name (str or None) – the name of the group to use, or None to use the default “Print Settings”

Raises:

GLib.Error

Returns:

the restored GtkPrintSettings

Return type:

Gtk.PrintSettings

Reads the print settings from the group group_name in key_file.

Returns a new GtkPrintSettings object with the restored settings, or None if an error occurred. If the file could not be loaded then error is set to either GFileError or GKeyFileError.

copy()[source]
Returns:

a newly allocated copy of self

Return type:

Gtk.PrintSettings

Copies a GtkPrintSettings object.

foreach(func, *user_data)[source]
Parameters:

Calls func for each key-value pair of self.

get(key)[source]
Parameters:

key (str) – a key

Returns:

the string value for key

Return type:

str or None

Looks up the string value associated with key.

get_bool(key)[source]
Parameters:

key (str) – a key

Returns:

True, if key maps to a true value.

Return type:

bool

Returns the boolean represented by the value that is associated with key.

The string “true” represents True, any other string False.

get_collate()[source]
Returns:

whether to collate the printed pages

Return type:

bool

Gets the value of Gtk.PRINT_SETTINGS_COLLATE.

get_default_source()[source]
Returns:

the default source

Return type:

str or None

Gets the value of Gtk.PRINT_SETTINGS_DEFAULT_SOURCE.

get_dither()[source]
Returns:

the dithering that is used

Return type:

str or None

Gets the value of Gtk.PRINT_SETTINGS_DITHER.

get_double(key)[source]
Parameters:

key (str) – a key

Returns:

the double value of key

Return type:

float

Returns the double value associated with key, or 0.

get_double_with_default(key, def_)[source]
Parameters:
  • key (str) – a key

  • def (float) – the default value

Returns:

the floating point number associated with key

Return type:

float

Returns the floating point number represented by the value that is associated with key, or default_val if the value does not represent a floating point number.

Floating point numbers are parsed with GLib.ascii_strtod().

get_duplex()[source]
Returns:

whether to print the output in duplex.

Return type:

Gtk.PrintDuplex

Gets the value of Gtk.PRINT_SETTINGS_DUPLEX.

get_finishings()[source]
Returns:

the finishings

Return type:

str or None

Gets the value of Gtk.PRINT_SETTINGS_FINISHINGS.

get_int(key)[source]
Parameters:

key (str) – a key

Returns:

the integer value of key

Return type:

int

Returns the integer value of key, or 0.

get_int_with_default(key, def_)[source]
Parameters:
  • key (str) – a key

  • def (int) – the default value

Returns:

the integer value of key

Return type:

int

Returns the value of key, interpreted as an integer, or the default value.

get_length(key, unit)[source]
Parameters:
  • key (str) – a key

  • unit (Gtk.Unit) – the unit of the return value

Returns:

the length value of key, converted to unit

Return type:

float

Returns the value associated with key, interpreted as a length.

The returned value is converted to units.

get_media_type()[source]
Returns:

the media type

Return type:

str or None

Gets the value of Gtk.PRINT_SETTINGS_MEDIA_TYPE.

The set of media types is defined in PWG 5101.1-2002 PWG.

get_n_copies()[source]
Returns:

the number of copies to print

Return type:

int

Gets the value of Gtk.PRINT_SETTINGS_N_COPIES.

get_number_up()[source]
Returns:

the number of pages per sheet

Return type:

int

Gets the value of Gtk.PRINT_SETTINGS_NUMBER_UP.

get_number_up_layout()[source]
Returns:

layout of page in number-up mode

Return type:

Gtk.NumberUpLayout

Gets the value of Gtk.PRINT_SETTINGS_NUMBER_UP_LAYOUT.

get_orientation()[source]
Returns:

the orientation

Return type:

Gtk.PageOrientation

Get the value of Gtk.PRINT_SETTINGS_ORIENTATION, converted to a GtkPageOrientation.

get_output_bin()[source]
Returns:

the output bin

Return type:

str or None

Gets the value of Gtk.PRINT_SETTINGS_OUTPUT_BIN.

get_page_ranges()[source]
Returns:

an array of ``GtkPageRange``s. Use GLib.free() to free the array when it is no longer needed.

Return type:

[Gtk.PageRange]

Gets the value of Gtk.PRINT_SETTINGS_PAGE_RANGES.

get_page_set()[source]
Returns:

the set of pages to print

Return type:

Gtk.PageSet

Gets the value of Gtk.PRINT_SETTINGS_PAGE_SET.

get_paper_height(unit)[source]
Parameters:

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

Returns:

the paper height, in units of unit

Return type:

float

Gets the value of Gtk.PRINT_SETTINGS_PAPER_HEIGHT, converted to unit.

get_paper_size()[source]
Returns:

the paper size

Return type:

Gtk.PaperSize or None

Gets the value of Gtk.PRINT_SETTINGS_PAPER_FORMAT, converted to a GtkPaperSize.

get_paper_width(unit)[source]
Parameters:

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

Returns:

the paper width, in units of unit

Return type:

float

Gets the value of Gtk.PRINT_SETTINGS_PAPER_WIDTH, converted to unit.

get_print_pages()[source]
Returns:

which pages to print

Return type:

Gtk.PrintPages

Gets the value of Gtk.PRINT_SETTINGS_PRINT_PAGES.

get_printer()[source]
Returns:

the printer name

Return type:

str or None

Convenience function to obtain the value of Gtk.PRINT_SETTINGS_PRINTER.

get_printer_lpi()[source]
Returns:

the resolution in lpi (lines per inch)

Return type:

float

Gets the value of Gtk.PRINT_SETTINGS_PRINTER_LPI.

get_quality()[source]
Returns:

the print quality

Return type:

Gtk.PrintQuality

Gets the value of Gtk.PRINT_SETTINGS_QUALITY.

get_resolution()[source]
Returns:

the resolution in dpi

Return type:

int

Gets the value of Gtk.PRINT_SETTINGS_RESOLUTION.

get_resolution_x()[source]
Returns:

the horizontal resolution in dpi

Return type:

int

Gets the value of Gtk.PRINT_SETTINGS_RESOLUTION_X.

get_resolution_y()[source]
Returns:

the vertical resolution in dpi

Return type:

int

Gets the value of Gtk.PRINT_SETTINGS_RESOLUTION_Y.

get_reverse()[source]
Returns:

whether to reverse the order of the printed pages

Return type:

bool

Gets the value of Gtk.PRINT_SETTINGS_REVERSE.

get_scale()[source]
Returns:

the scale in percent

Return type:

float

Gets the value of Gtk.PRINT_SETTINGS_SCALE.

get_use_color()[source]
Returns:

whether to use color

Return type:

bool

Gets the value of Gtk.PRINT_SETTINGS_USE_COLOR.

has_key(key)[source]
Parameters:

key (str) – a key

Returns:

True, if key has a value

Return type:

bool

Returns True, if a value is associated with key.

load_file(file_name)[source]
Parameters:

file_name (str) – the filename to read the settings from

Raises:

GLib.Error

Returns:

True on success

Return type:

bool

Reads the print settings from file_name.

If the file could not be loaded then error is set to either a GFileError or GKeyFileError.

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

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

  • group_name (str or None) – the name of the group to use, or None to use the default “Print Settings”

Raises:

GLib.Error

Returns:

True on success

Return type:

bool

Reads the print settings from the group group_name in key_file.

If the file could not be loaded then error is set to either a GFileError or GKeyFileError.

set(key, value)[source]
Parameters:
  • key (str) – a key

  • value (str or None) – a string value

Associates value with key.

set_bool(key, value)[source]
Parameters:
  • key (str) – a key

  • value (bool) – a boolean

Sets key to a boolean value.

set_collate(collate)[source]
Parameters:

collate (bool) – whether to collate the output

Sets the value of Gtk.PRINT_SETTINGS_COLLATE.

set_default_source(default_source)[source]
Parameters:

default_source (str) – the default source

Sets the value of Gtk.PRINT_SETTINGS_DEFAULT_SOURCE.

set_dither(dither)[source]
Parameters:

dither (str) – the dithering that is used

Sets the value of Gtk.PRINT_SETTINGS_DITHER.

set_double(key, value)[source]
Parameters:
  • key (str) – a key

  • value (float) – a double value

Sets key to a double value.

set_duplex(duplex)[source]
Parameters:

duplex (Gtk.PrintDuplex) – a GtkPrintDuplex value

Sets the value of Gtk.PRINT_SETTINGS_DUPLEX.

set_finishings(finishings)[source]
Parameters:

finishings (str) – the finishings

Sets the value of Gtk.PRINT_SETTINGS_FINISHINGS.

set_int(key, value)[source]
Parameters:
  • key (str) – a key

  • value (int) – an integer

Sets key to an integer value.

set_length(key, value, unit)[source]
Parameters:
  • key (str) – a key

  • value (float) – a length

  • unit (Gtk.Unit) – the unit of length

Associates a length in units of unit with key.

set_media_type(media_type)[source]
Parameters:

media_type (str) – the media type

Sets the value of Gtk.PRINT_SETTINGS_MEDIA_TYPE.

The set of media types is defined in PWG 5101.1-2002 PWG.

set_n_copies(num_copies)[source]
Parameters:

num_copies (int) – the number of copies

Sets the value of Gtk.PRINT_SETTINGS_N_COPIES.

set_number_up(number_up)[source]
Parameters:

number_up (int) – the number of pages per sheet

Sets the value of Gtk.PRINT_SETTINGS_NUMBER_UP.

set_number_up_layout(number_up_layout)[source]
Parameters:

number_up_layout (Gtk.NumberUpLayout) – a GtkNumberUpLayout value

Sets the value of Gtk.PRINT_SETTINGS_NUMBER_UP_LAYOUT.

set_orientation(orientation)[source]
Parameters:

orientation (Gtk.PageOrientation) – a page orientation

Sets the value of Gtk.PRINT_SETTINGS_ORIENTATION.

set_output_bin(output_bin)[source]
Parameters:

output_bin (str) – the output bin

Sets the value of Gtk.PRINT_SETTINGS_OUTPUT_BIN.

set_page_ranges(page_ranges)[source]
Parameters:

page_ranges ([Gtk.PageRange]) – an array of ``GtkPageRange``s

Sets the value of Gtk.PRINT_SETTINGS_PAGE_RANGES.

set_page_set(page_set)[source]
Parameters:

page_set (Gtk.PageSet) – a GtkPageSet value

Sets the value of Gtk.PRINT_SETTINGS_PAGE_SET.

set_paper_height(height, unit)[source]
Parameters:
  • height (float) – the paper height

  • unit (Gtk.Unit) – the units of height

Sets the value of Gtk.PRINT_SETTINGS_PAPER_HEIGHT.

set_paper_size(paper_size)[source]
Parameters:

paper_size (Gtk.PaperSize) – a paper size

Sets the value of Gtk.PRINT_SETTINGS_PAPER_FORMAT, Gtk.PRINT_SETTINGS_PAPER_WIDTH and Gtk.PRINT_SETTINGS_PAPER_HEIGHT.

set_paper_width(width, unit)[source]
Parameters:
  • width (float) – the paper width

  • unit (Gtk.Unit) – the units of width

Sets the value of Gtk.PRINT_SETTINGS_PAPER_WIDTH.

set_print_pages(pages)[source]
Parameters:

pages (Gtk.PrintPages) – a GtkPrintPages value

Sets the value of Gtk.PRINT_SETTINGS_PRINT_PAGES.

set_printer(printer)[source]
Parameters:

printer (str) – the printer name

Convenience function to set Gtk.PRINT_SETTINGS_PRINTER to printer.

set_printer_lpi(lpi)[source]
Parameters:

lpi (float) – the resolution in lpi (lines per inch)

Sets the value of Gtk.PRINT_SETTINGS_PRINTER_LPI.

set_quality(quality)[source]
Parameters:

quality (Gtk.PrintQuality) – a GtkPrintQuality value

Sets the value of Gtk.PRINT_SETTINGS_QUALITY.

set_resolution(resolution)[source]
Parameters:

resolution (int) – the resolution in dpi

Sets the values of Gtk.PRINT_SETTINGS_RESOLUTION, Gtk.PRINT_SETTINGS_RESOLUTION_X and Gtk.PRINT_SETTINGS_RESOLUTION_Y.

set_resolution_xy(resolution_x, resolution_y)[source]
Parameters:
  • resolution_x (int) – the horizontal resolution in dpi

  • resolution_y (int) – the vertical resolution in dpi

Sets the values of Gtk.PRINT_SETTINGS_RESOLUTION, Gtk.PRINT_SETTINGS_RESOLUTION_X and Gtk.PRINT_SETTINGS_RESOLUTION_Y.

set_reverse(reverse)[source]
Parameters:

reverse (bool) – whether to reverse the output

Sets the value of Gtk.PRINT_SETTINGS_REVERSE.

set_scale(scale)[source]
Parameters:

scale (float) – the scale in percent

Sets the value of Gtk.PRINT_SETTINGS_SCALE.

set_use_color(use_color)[source]
Parameters:

use_color (bool) – whether to use color

Sets the value of Gtk.PRINT_SETTINGS_USE_COLOR.

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 print settings from self to file_name.

If the file could not be written then error is set to either a GFileError or GKeyFileError.

to_gvariant()[source]
Returns:

a new, floating, GVariant

Return type:

GLib.Variant

Serialize print settings to an a{sv} variant.

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

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

This function adds the print settings from self to key_file.

unset(key)[source]
Parameters:

key (str) – a key

Removes any value associated with key.

This has the same effect as setting the value to None.