:right-sidebar: True PrintSettings =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: PrintSettings(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` :Constructors: :: PrintSettings(**properties) new() -> Gtk.PrintSettings new_from_file(file_name:str) -> Gtk.PrintSettings new_from_gvariant(variant:GLib.Variant) -> Gtk.PrintSettings new_from_key_file(key_file:GLib.KeyFile, group_name:str=None) -> Gtk.PrintSettings Constructors ------------ .. rst-class:: interim-class .. class:: PrintSettings :no-index: .. classmethod:: new() -> ~gi.repository.Gtk.PrintSettings Creates a new ``GtkPrintSettings`` object. .. classmethod:: new_from_file(file_name: str) -> ~gi.repository.Gtk.PrintSettings Reads the print settings from ``file_name``. Returns a new ``GtkPrintSettings`` object with the restored settings, or :const:`None` if an error occurred. If the file could not be loaded then error is set to either a ``GFileError`` or ``GKeyFileError``. See :obj:`~gi.repository.Gtk.PrintSettings.to_file`. :param file_name: the filename to read the settings from .. classmethod:: new_from_gvariant(variant: ~gi.repository.GLib.Variant) -> ~gi.repository.Gtk.PrintSettings Deserialize print settings from an a{sv} variant. The variant must be in the format produced by :obj:`~gi.repository.Gtk.PrintSettings.to_gvariant`. :param variant: an a{sv} ``GVariant`` .. classmethod:: new_from_key_file(key_file: ~gi.repository.GLib.KeyFile, group_name: str | None = None) -> ~gi.repository.Gtk.PrintSettings Reads the print settings from the group ``group_name`` in ``key_file``. Returns a new ``GtkPrintSettings`` object with the restored settings, or :const:`None` if an error occurred. If the file could not be loaded then error is set to either ``GFileError`` or ``GKeyFileError``. :param key_file: the ``GKeyFile`` to retrieve the settings from :param group_name: the name of the group to use, or :const:`None` to use the default “Print Settings” Methods ------- .. rst-class:: interim-class .. class:: PrintSettings :no-index: .. method:: foreach(func: ~typing.Callable[[...], None], *user_data: ~typing.Any) -> None Calls ``func`` for each key-value pair of ``settings``. :param func: the function to call :param user_data: user data for ``func`` .. method:: get(key: str) -> str | None Looks up the string value associated with ``key``. :param key: a key .. method:: get_bool(key: str) -> bool Returns the boolean represented by the value that is associated with ``key``. The string “true” represents :const:`True`, any other string :const:`False`. :param key: a key .. method:: get_collate() -> bool Gets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_COLLATE`. .. method:: get_default_source() -> str | None Gets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_DEFAULT_SOURCE`. .. method:: get_dither() -> str | None Gets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_DITHER`. .. method:: get_double(key: str) -> float Returns the double value associated with ``key``, or 0. :param key: a key .. method:: get_double_with_default(key: str, def_: float) -> 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 :func:`~gi.repository.GLib.ascii_strtod`. :param key: a key :param def_: .. method:: get_duplex() -> ~gi.repository.Gtk.PrintDuplex Gets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_DUPLEX`. .. method:: get_finishings() -> str | None Gets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_FINISHINGS`. .. method:: get_int(key: str) -> int Returns the integer value of ``key``, or 0. :param key: a key .. method:: get_int_with_default(key: str, def_: int) -> int Returns the value of ``key``, interpreted as an integer, or the default value. :param key: a key :param def_: .. method:: get_length(key: str, unit: ~gi.repository.Gtk.Unit) -> float Returns the value associated with ``key``, interpreted as a length. The returned value is converted to ``units``. :param key: a key :param unit: the unit of the return value .. method:: get_media_type() -> str | None Gets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_MEDIA_TYPE`. The set of media types is defined in PWG 5101.1-2002 PWG. .. method:: get_n_copies() -> int Gets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_N_COPIES`. .. method:: get_number_up() -> int Gets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_NUMBER_UP`. .. method:: get_number_up_layout() -> ~gi.repository.Gtk.NumberUpLayout Gets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_NUMBER_UP_LAYOUT`. .. method:: get_orientation() -> ~gi.repository.Gtk.PageOrientation Get the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_ORIENTATION`, converted to a ``GtkPageOrientation``. .. method:: get_output_bin() -> str | None Gets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_OUTPUT_BIN`. .. method:: get_page_ranges() -> list[~gi.repository.Gtk.PageRange] Gets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_PAGE_RANGES`. .. method:: get_page_set() -> ~gi.repository.Gtk.PageSet Gets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_PAGE_SET`. .. method:: get_paper_height(unit: ~gi.repository.Gtk.Unit) -> float Gets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_PAPER_HEIGHT`, converted to ``unit``. :param unit: the unit for the return value .. method:: get_paper_size() -> ~gi.repository.Gtk.PaperSize | None Gets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_PAPER_FORMAT`, converted to a ``GtkPaperSize``. .. method:: get_paper_width(unit: ~gi.repository.Gtk.Unit) -> float Gets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_PAPER_WIDTH`, converted to ``unit``. :param unit: the unit for the return value .. method:: get_print_pages() -> ~gi.repository.Gtk.PrintPages Gets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_PRINT_PAGES`. .. method:: get_printer() -> str | None Convenience function to obtain the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_PRINTER`. .. method:: get_printer_lpi() -> float Gets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_PRINTER_LPI`. .. method:: get_quality() -> ~gi.repository.Gtk.PrintQuality Gets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_QUALITY`. .. method:: get_resolution() -> int Gets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_RESOLUTION`. .. method:: get_resolution_x() -> int Gets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_RESOLUTION_X`. .. method:: get_resolution_y() -> int Gets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_RESOLUTION_Y`. .. method:: get_reverse() -> bool Gets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_REVERSE`. .. method:: get_scale() -> float Gets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_SCALE`. .. method:: get_use_color() -> bool Gets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_USE_COLOR`. .. method:: has_key(key: str) -> bool Returns :const:`True`, if a value is associated with ``key``. :param key: a key .. method:: load_file(file_name: str) -> 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 :obj:`~gi.repository.Gtk.PrintSettings.to_file`. :param file_name: the filename to read the settings from .. method:: load_key_file(key_file: ~gi.repository.GLib.KeyFile, group_name: str | None = None) -> 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``. :param key_file: the ``GKeyFile`` to retrieve the settings from :param group_name: the name of the group to use, or :const:`None` to use the default “Print Settings” .. method:: set(key: str, value: str | None = None) -> None Associates ``value`` with ``key``. :param key: a key :param value: a string value .. method:: set_bool(key: str, value: bool) -> None Sets ``key`` to a boolean value. :param key: a key :param value: a boolean .. method:: set_collate(collate: bool) -> None Sets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_COLLATE`. :param collate: whether to collate the output .. method:: set_default_source(default_source: str) -> None Sets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_DEFAULT_SOURCE`. :param default_source: the default source .. method:: set_dither(dither: str) -> None Sets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_DITHER`. :param dither: the dithering that is used .. method:: set_double(key: str, value: float) -> None Sets ``key`` to a double value. :param key: a key :param value: a double value .. method:: set_duplex(duplex: ~gi.repository.Gtk.PrintDuplex) -> None Sets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_DUPLEX`. :param duplex: a ``GtkPrintDuplex`` value .. method:: set_finishings(finishings: str) -> None Sets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_FINISHINGS`. :param finishings: the finishings .. method:: set_int(key: str, value: int) -> None Sets ``key`` to an integer value. :param key: a key :param value: an integer .. method:: set_length(key: str, value: float, unit: ~gi.repository.Gtk.Unit) -> None Associates a length in units of ``unit`` with ``key``. :param key: a key :param value: a length :param unit: the unit of ``length`` .. method:: set_media_type(media_type: str) -> None Sets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_MEDIA_TYPE`. The set of media types is defined in PWG 5101.1-2002 PWG. :param media_type: the media type .. method:: set_n_copies(num_copies: int) -> None Sets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_N_COPIES`. :param num_copies: the number of copies .. method:: set_number_up(number_up: int) -> None Sets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_NUMBER_UP`. :param number_up: the number of pages per sheet .. method:: set_number_up_layout(number_up_layout: ~gi.repository.Gtk.NumberUpLayout) -> None Sets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_NUMBER_UP_LAYOUT`. :param number_up_layout: a ``GtkNumberUpLayout`` value .. method:: set_orientation(orientation: ~gi.repository.Gtk.PageOrientation) -> None Sets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_ORIENTATION`. :param orientation: a page orientation .. method:: set_output_bin(output_bin: str) -> None Sets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_OUTPUT_BIN`. :param output_bin: the output bin .. method:: set_page_ranges(page_ranges: ~typing.Sequence[~gi.repository.Gtk.PageRange]) -> None Sets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_PAGE_RANGES`. :param page_ranges: an array of ``GtkPageRange``'s .. method:: set_page_set(page_set: ~gi.repository.Gtk.PageSet) -> None Sets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_PAGE_SET`. :param page_set: a ``GtkPageSet`` value .. method:: set_paper_height(height: float, unit: ~gi.repository.Gtk.Unit) -> None Sets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_PAPER_HEIGHT`. :param height: the paper height :param unit: the units of ``height`` .. method:: set_paper_size(paper_size: ~gi.repository.Gtk.PaperSize) -> None Sets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_PAPER_FORMAT`, :const:`~gi.repository.Gtk.PRINT_SETTINGS_PAPER_WIDTH` and :const:`~gi.repository.Gtk.PRINT_SETTINGS_PAPER_HEIGHT`. :param paper_size: a paper size .. method:: set_paper_width(width: float, unit: ~gi.repository.Gtk.Unit) -> None Sets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_PAPER_WIDTH`. :param width: the paper width :param unit: the units of ``width`` .. method:: set_print_pages(pages: ~gi.repository.Gtk.PrintPages) -> None Sets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_PRINT_PAGES`. :param pages: a ``GtkPrintPages`` value .. method:: set_printer(printer: str) -> None Convenience function to set :const:`~gi.repository.Gtk.PRINT_SETTINGS_PRINTER` to ``printer``. :param printer: the printer name .. method:: set_printer_lpi(lpi: float) -> None Sets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_PRINTER_LPI`. :param lpi: the resolution in lpi (lines per inch) .. method:: set_quality(quality: ~gi.repository.Gtk.PrintQuality) -> None Sets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_QUALITY`. :param quality: a ``GtkPrintQuality`` value .. method:: set_resolution(resolution: int) -> None Sets the values of :const:`~gi.repository.Gtk.PRINT_SETTINGS_RESOLUTION`, :const:`~gi.repository.Gtk.PRINT_SETTINGS_RESOLUTION_X` and :const:`~gi.repository.Gtk.PRINT_SETTINGS_RESOLUTION_Y`. :param resolution: the resolution in dpi .. method:: set_resolution_xy(resolution_x: int, resolution_y: int) -> None Sets the values of :const:`~gi.repository.Gtk.PRINT_SETTINGS_RESOLUTION`, :const:`~gi.repository.Gtk.PRINT_SETTINGS_RESOLUTION_X` and :const:`~gi.repository.Gtk.PRINT_SETTINGS_RESOLUTION_Y`. :param resolution_x: the horizontal resolution in dpi :param resolution_y: the vertical resolution in dpi .. method:: set_reverse(reverse: bool) -> None Sets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_REVERSE`. :param reverse: whether to reverse the output .. method:: set_scale(scale: float) -> None Sets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_SCALE`. :param scale: the scale in percent .. method:: set_use_color(use_color: bool) -> None Sets the value of :const:`~gi.repository.Gtk.PRINT_SETTINGS_USE_COLOR`. :param use_color: whether to use color .. method:: to_file(file_name: str) -> bool 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``. :param file_name: the file to save to .. method:: to_gvariant() -> ~gi.repository.GLib.Variant Serialize print settings to an a{sv} variant. .. method:: to_key_file(key_file: ~gi.repository.GLib.KeyFile, group_name: str | None = None) -> None This function adds the print settings from ``settings`` to ``key_file``. :param key_file: the ``GKeyFile`` to save the print settings to :param group_name: the group to add the settings to in ``key_file``, or :const:`None` to use the default “Print Settings” .. method:: unset(key: str) -> None Removes any value associated with ``key``. This has the same effect as setting the value to :const:`None`. :param key: a key