GLib.OptionGroup¶
record (struct)
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¶
new¶
@classmethod
def new(cls, name: str, description: str, help_description: str, user_data: int | None = ..., destroy: DestroyNotify | None = ...) -> OptionGroup
Creates a new 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:’.
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 ofOptionArg.CALLBACKoptions, orNonedestroy— a function that will be called to freeuser_data, orNone
Methods¶
add_entries¶
Adds the options specified in entries to group.
Parameters:
entries— aNone-terminated array ofGOptionEntrys
free¶
:::warning Deprecated since 2.44 This API is deprecated. :::
Frees a OptionGroup. Note that you must not free groups
which have been added to a OptionContext.
ref¶
Increments the reference count of group by one.
set_translate_func¶
Sets the function which is used to translate user-visible strings,
for --help output. Different groups can use different
GTranslateFuncs. If func is None, strings are not translated.
If you are using gettext(), you only need to set the translation
domain, see OptionGroup.set_translation_domain.
Parameters:
func— theGTranslateFunc, orNone
set_translation_domain¶
A convenience function to use gettext() for translating user-visible strings.
Parameters:
domain— the domain to use
unref¶
Decrements the reference count of group by one.
If the reference count drops to 0, the group will be freed.
and all memory allocated by the group is released.