:right-sidebar: True OptionGroup =================================================================== .. currentmodule:: gi.repository.GLib .. class:: OptionGroup(**kwargs) :no-contents-entry: A ``GOptionGroup`` struct defines the options in a single group. The struct has only private fields and should not be directly accessed. All options in a group share the same translation function. Libraries which need to parse commandline options are expected to provide a function for getting a ``GOptionGroup`` holding their options, which the application can then add to its :obj:`~gi.repository.GLib.OptionContext`\. Constructors ------------ .. rst-class:: interim-class .. class:: OptionGroup :no-index: .. classmethod:: new(name: str, description: str, help_description: str, user_data: ~typing.Any = None, destroy: ~collections.abc.Callable[[~typing.Any], None] | None = None) -> ~gi.repository.GLib.OptionGroup Creates a new :obj:`~gi.repository.GLib.OptionGroup`\. ``description`` is typically used to provide a title for the group. If so, it is recommended that it’s written in title case, and has a trailing colon so that it matches the style of built-in GLib group titles such as ‘Application Options:’. .. versionadded:: 2.6 :param name: the name for the option group, this is used to provide help for the options in this group with ``--help-````name`` :param description: a description for this group to be shown in ``--help``\. This string is translated using the translation domain or translation function of the group :param help_description: a description for the ``--help-````name`` option. This string is translated using the translation domain or translation function of the group :param user_data: user data that will be passed to the pre- and post-parse hooks, the error hook and to callbacks of :const:`~gi.repository.GLib.OptionArg.CALLBACK` options, or :const:`None` :param destroy: a function that will be called to free ``user_data``\, or :const:`None` Methods ------- .. rst-class:: interim-class .. class:: OptionGroup :no-index: .. method:: add_entries(entries: list[~gi.repository.GLib.OptionEntry]) -> None Adds the options specified in ``entries`` to ``group``\. .. versionadded:: 2.6 :param entries: a :const:`None`-terminated array of :obj:`~gi.repository.GLib.OptionEntry` .. method:: free() -> None Frees a :obj:`~gi.repository.GLib.OptionGroup`\. Note that you must not free groups which have been added to a :obj:`~gi.repository.GLib.OptionContext`\. .. versionadded:: 2.6 .. deprecated:: 2.44 Use :func:`~gi.repository.GLib.OptionGroup.unref` instead. .. method:: set_translate_func(func: ~collections.abc.Callable[[str, ~typing.Any], str] | None = None, data: ~typing.Any = None) -> None Sets the function which is used to translate user-visible strings, for ``--help`` output. Different groups can use different :obj:`~gi.repository.GLib.TranslateFunc`\. If ``func`` is :const:`None`, strings are not translated. If you are using gettext(), you only need to set the translation domain, see :func:`~gi.repository.GLib.OptionGroup.set_translation_domain`. .. versionadded:: 2.6 :param func: the :obj:`~gi.repository.GLib.TranslateFunc`\, or :const:`None` :param data: user data to pass to ``func``\, or :const:`None` .. method:: set_translation_domain(domain: str) -> None A convenience function to use gettext() for translating user-visible strings. .. versionadded:: 2.6 :param domain: the domain to use