OptionGroup#
- class OptionGroup(**kwargs)#
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 OptionContext.
Constructors#
- class OptionGroup
- classmethod new(name: str, description: str, help_description: str, user_data: Any = None, destroy: Callable[[Any], None] | None = None) OptionGroup#
Creates a new
OptionGroup.descriptionis 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:’.Added in version 2.6.
- Parameters:
name – the name for the option group, this is used to provide help for the options in this group with
--help-````namedescription – a description for this group to be shown in
--help. This string is translated using the translation domain or translation function of the grouphelp_description – a description for the
--help-````nameoption. This string is translated using the translation domain or translation function of the groupuser_data – user data that will be passed to the pre- and post-parse hooks, the error hook and to callbacks of
CALLBACKoptions, orNonedestroy – a function that will be called to free
user_data, orNone
Methods#
- class OptionGroup
- add_entries(entries: list[OptionEntry]) None#
Adds the options specified in
entriestogroup.Added in version 2.6.
- Parameters:
entries – a
None-terminated array ofOptionEntry
- free() None#
Frees a
OptionGroup. Note that you must not free groups which have been added to aOptionContext.Added in version 2.6.
Deprecated since version 2.44: Use
unref()instead.
- set_translate_func(func: Callable[[str, Any], str] | None = None, data: Any = None) None#
Sets the function which is used to translate user-visible strings, for
--helpoutput. Different groups can use differentTranslateFunc. IffuncisNone, strings are not translated.If you are using gettext(), you only need to set the translation domain, see
set_translation_domain().Added in version 2.6.
- Parameters:
func – the
TranslateFunc, orNonedata – user data to pass to
func, orNone