Options Manager#

class ignis.options.OptionsManager(file: str | None = None)#

Bases: OptionsGroup.

This is the top-level class in the option structure. It provides support for loading and saving options to a file.

Parameters:

file (str | None, default: None) -- The path to the file used for saving and loading options. Cannot be changed after initialization.

The standard option structure must follow this format:

from ignis.options_manager import OptionsManager, OptionsGroup

class SomeOptions(OptionsManager):
    def __init__(self):
        super().__init__(file="PATH/TO/FILE")

    class Subgroup1(OptionsGroup):
        option1: bool = False
        option2: int = 5000

    class SomeSubgroup(OptionsGroup):
        example_option: str | None = get_something...()
        test: str = "%Y-%m-%d_%H-%M-%S.mp4"


    subgroup1 = Subgroup1()
    some_subgroup = SomeSubgroup()

some_options = SomeOptions()
save_to_file(file: str) None#

Manually save options to the specified file.

Parameters:

file (str) -- The path to the file where options will be saved.

Return type:

None

load_from_file(file: str) None#

Manually load options from the specified file.

Parameters:

file (str) -- The path to the file from which options will be loaded.

Return type:

None

class ignis.options.OptionsGroup(*args: Any, **kwargs: Any)#

An options group.

changed(*args)#
  • Signal

Emitted when an option of this group has changed

Parameters:

option_name -- The name of the option.

subgroup_changed(*args)#
  • Signal

Emitted when an option of a subgroup has changed

Parameters:
  • subgroup_name -- The name of the subgroup.

  • option_name -- The name of the option.

connect_option(option_name: str, callback: Callable, *args) None#

Connect an option change event to the specified callback.

This method serves as a replacement for the notify signal, as options are simple Python properties, not GObject properties.

Parameters:
  • option_name (str) -- The name of the option to connect.

  • callback (Callable) -- The function to invoke when the value of the option changes.

Return type:

None

Any *args will be passed to the callback.

to_dict() dict[str, Any]#

Returns a dictionary representation of all options and subgroups.

Return type:

dict[str, Any]

apply_from_dict(data: dict[str, Any]) None#

Apply values to options from a dictionary.

Parameters:

data (dict[str, Any]) -- A dictionary containing the values to apply.

Return type:

None