Gtk.PrintSettings¶
class — extends GObject.Object
Collects 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.
Constructors¶
new¶
Creates a new GtkPrintSettings object.
new_from_file¶
@classmethod
def new_from_file(cls, file_name: str | bytes | os.PathLike[str] | os.PathLike[bytes]) -> 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.
Parameters:
file_name— the filename to read the settings from
new_from_gvariant¶
Deserialize print settings from an a{sv} variant.
The variant must be in the format produced by
PrintSettings.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 = ...) -> 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.
Parameters:
key_file— theGKeyFileto retrieve the settings fromgroup_name— the name of the group to use, orNoneto use the default “Print Settings”
Methods¶
copy¶
Copies a GtkPrintSettings object.
foreach¶
Calls func for each key-value pair of settings.
Parameters:
func— the function to call
get¶
Looks up the string value associated with key.
Parameters:
key— a key
get_bool¶
Returns the boolean represented by the value
that is associated with key.
The string “true” represents True, any other
string False.
Parameters:
key— a key
get_collate¶
Gets the value of PRINT_SETTINGS_COLLATE.
get_default_source¶
Gets the value of PRINT_SETTINGS_DEFAULT_SOURCE.
get_dither¶
Gets the value of PRINT_SETTINGS_DITHER.
get_double¶
Returns the double value associated with key, or 0.
Parameters:
key— a key
get_double_with_default¶
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.
Parameters:
key— a keydef_— the default value
get_duplex¶
Gets the value of PRINT_SETTINGS_DUPLEX.
get_finishings¶
Gets the value of PRINT_SETTINGS_FINISHINGS.
get_int¶
Returns the integer value of key, or 0.
Parameters:
key— a key
get_int_with_default¶
Returns the value of key, interpreted as
an integer, or the default value.
Parameters:
key— a keydef_— the default value
get_length¶
Returns the value associated with key, interpreted
as a length.
The returned value is converted to units.
Parameters:
key— a keyunit— the unit of the return value
get_media_type¶
Gets the value of PRINT_SETTINGS_MEDIA_TYPE.
The set of media types is defined in PWG 5101.1-2002 PWG.
get_n_copies¶
Gets the value of PRINT_SETTINGS_N_COPIES.
get_number_up¶
Gets the value of PRINT_SETTINGS_NUMBER_UP.
get_number_up_layout¶
Gets the value of PRINT_SETTINGS_NUMBER_UP_LAYOUT.
get_orientation¶
Get the value of PRINT_SETTINGS_ORIENTATION,
converted to a GtkPageOrientation.
get_output_bin¶
Gets the value of PRINT_SETTINGS_OUTPUT_BIN.
get_page_ranges¶
Gets the value of PRINT_SETTINGS_PAGE_RANGES.
get_page_set¶
Gets the value of PRINT_SETTINGS_PAGE_SET.
get_paper_height¶
Gets the value of PRINT_SETTINGS_PAPER_HEIGHT,
converted to unit.
Parameters:
unit— the unit for the return value
get_paper_size¶
Gets the value of PRINT_SETTINGS_PAPER_FORMAT,
converted to a GtkPaperSize.
get_paper_width¶
Gets the value of PRINT_SETTINGS_PAPER_WIDTH,
converted to unit.
Parameters:
unit— the unit for the return value
get_print_pages¶
Gets the value of PRINT_SETTINGS_PRINT_PAGES.
get_printer¶
Convenience function to obtain the value of
PRINT_SETTINGS_PRINTER.
get_printer_lpi¶
Gets the value of PRINT_SETTINGS_PRINTER_LPI.
get_quality¶
Gets the value of PRINT_SETTINGS_QUALITY.
get_resolution¶
Gets the value of PRINT_SETTINGS_RESOLUTION.
get_resolution_x¶
Gets the value of PRINT_SETTINGS_RESOLUTION_X.
get_resolution_y¶
Gets the value of PRINT_SETTINGS_RESOLUTION_Y.
get_reverse¶
Gets the value of PRINT_SETTINGS_REVERSE.
get_scale¶
Gets the value of PRINT_SETTINGS_SCALE.
get_use_color¶
Gets the value of PRINT_SETTINGS_USE_COLOR.
has_key¶
Returns True, if a value is associated with key.
Parameters:
key— a key
load_file¶
Reads the print settings from file_name.
If the file could not be loaded then error is set to either
a GFileError or GKeyFileError.
Parameters:
file_name— the filename to read the settings from
load_key_file¶
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.
Parameters:
key_file— theGKeyFileto retrieve the settings fromgroup_name— the name of the group to use, orNoneto use the default “Print Settings”
set¶
Associates value with key.
Parameters:
key— a keyvalue— a string value
set_bool¶
Sets key to a boolean value.
Parameters:
key— a keyvalue— a boolean
set_collate¶
Sets the value of PRINT_SETTINGS_COLLATE.
Parameters:
collate— whether to collate the output
set_default_source¶
Sets the value of PRINT_SETTINGS_DEFAULT_SOURCE.
Parameters:
default_source— the default source
set_dither¶
Sets the value of PRINT_SETTINGS_DITHER.
Parameters:
dither— the dithering that is used
set_double¶
Sets key to a double value.
Parameters:
key— a keyvalue— a double value
set_duplex¶
Sets the value of PRINT_SETTINGS_DUPLEX.
Parameters:
duplex— aGtkPrintDuplexvalue
set_finishings¶
Sets the value of PRINT_SETTINGS_FINISHINGS.
Parameters:
finishings— the finishings
set_int¶
Sets key to an integer value.
Parameters:
key— a keyvalue— an integer
set_length¶
Associates a length in units of unit with key.
Parameters:
key— a keyvalue— a lengthunit— the unit oflength
set_media_type¶
Sets the value of PRINT_SETTINGS_MEDIA_TYPE.
The set of media types is defined in PWG 5101.1-2002 PWG.
Parameters:
media_type— the media type
set_n_copies¶
Sets the value of PRINT_SETTINGS_N_COPIES.
Parameters:
num_copies— the number of copies
set_number_up¶
Sets the value of PRINT_SETTINGS_NUMBER_UP.
Parameters:
number_up— the number of pages per sheet
set_number_up_layout¶
Sets the value of PRINT_SETTINGS_NUMBER_UP_LAYOUT.
Parameters:
number_up_layout— aGtkNumberUpLayoutvalue
set_orientation¶
Sets the value of PRINT_SETTINGS_ORIENTATION.
Parameters:
orientation— a page orientation
set_output_bin¶
Sets the value of PRINT_SETTINGS_OUTPUT_BIN.
Parameters:
output_bin— the output bin
set_page_ranges¶
Sets the value of PRINT_SETTINGS_PAGE_RANGES.
Parameters:
page_ranges— an array ofGtkPageRanges
set_page_set¶
Sets the value of PRINT_SETTINGS_PAGE_SET.
Parameters:
page_set— aGtkPageSetvalue
set_paper_height¶
Sets the value of PRINT_SETTINGS_PAPER_HEIGHT.
Parameters:
height— the paper heightunit— the units ofheight
set_paper_size¶
Sets the value of PRINT_SETTINGS_PAPER_FORMAT,
PRINT_SETTINGS_PAPER_WIDTH and
PRINT_SETTINGS_PAPER_HEIGHT.
Parameters:
paper_size— a paper size
set_paper_width¶
Sets the value of PRINT_SETTINGS_PAPER_WIDTH.
Parameters:
width— the paper widthunit— the units ofwidth
set_print_pages¶
Sets the value of PRINT_SETTINGS_PRINT_PAGES.
Parameters:
pages— aGtkPrintPagesvalue
set_printer¶
Convenience function to set PRINT_SETTINGS_PRINTER
to printer.
Parameters:
printer— the printer name
set_printer_lpi¶
Sets the value of PRINT_SETTINGS_PRINTER_LPI.
Parameters:
lpi— the resolution in lpi (lines per inch)
set_quality¶
Sets the value of PRINT_SETTINGS_QUALITY.
Parameters:
quality— aGtkPrintQualityvalue
set_resolution¶
Sets the values of PRINT_SETTINGS_RESOLUTION,
PRINT_SETTINGS_RESOLUTION_X and
PRINT_SETTINGS_RESOLUTION_Y.
Parameters:
resolution— the resolution in dpi
set_resolution_xy¶
Sets the values of PRINT_SETTINGS_RESOLUTION,
PRINT_SETTINGS_RESOLUTION_X and
PRINT_SETTINGS_RESOLUTION_Y.
Parameters:
resolution_x— the horizontal resolution in dpiresolution_y— the vertical resolution in dpi
set_reverse¶
Sets the value of PRINT_SETTINGS_REVERSE.
Parameters:
reverse— whether to reverse the output
set_scale¶
Sets the value of PRINT_SETTINGS_SCALE.
Parameters:
scale— the scale in percent
set_use_color¶
Sets the value of PRINT_SETTINGS_USE_COLOR.
Parameters:
use_color— whether to use color
to_file¶
This function saves the print settings from settings to file_name.
If the file could not be written then error is set to either a
GFileError or GKeyFileError.
Parameters:
file_name— the file to save to
to_gvariant¶
Serialize print settings to an a{sv} variant.
to_key_file¶
This function adds the print settings from settings to key_file.
Parameters:
key_file— theGKeyFileto save the print settings togroup_name— the group to add the settings to inkey_file, orNoneto use the default “Print Settings”
unset¶
Removes any value associated with key.
This has the same effect as setting the value to None.
Parameters:
key— a key