Skip to content

fxconfig

fxconfig

Configuration and settings management for fxgui.

This module provides persistent storage for application settings using QSettings with INI format. Settings are stored in platform-appropriate locations: - Windows: %APPDATA%/fxgui/settings.ini - Unix/macOS: ~/.fxgui/settings.ini

Functions:

Name Description
get_settings

Get the QSettings instance for fxgui.

get_config_dir

Get the configuration directory path.

get_value

Get a setting value.

set_value

Set a setting value.

Examples:

Getting and setting values:

>>> from fxgui import fxconfig
>>> fxconfig.set_value("theme/current", "dracula")
>>> theme = fxconfig.get_value("theme/current", "dark")

Functions:

get_application_name

get_application_name() -> str

Return the application name settings are currently scoped under.

Returns:

Type Description
str

The current application name ("fxgui" unless changed via

str

set_application_name()).

get_config_dir

get_config_dir() -> Path

Get the configuration directory path.

The directory is created if it doesn't exist.

Returns:

Type Description
Path

Path to the configuration directory.

Examples:

>>> config_dir = fxconfig.get_config_dir()
>>> print(config_dir)  # C:/Users/user/AppData/Roaming/fxgui (Windows)

get_settings

get_settings() -> QSettings

Get the QSettings instance for fxgui.

Settings are stored in an INI file at the platform-appropriate location. The instance is cached for reuse.

Returns:

Type Description
QSettings

QSettings instance configured for fxgui using INI format.

Examples:

>>> settings = fxconfig.get_settings()
>>> settings.setValue("my/key", "my_value")
>>> settings.sync()

get_value

get_value(key: str, default: Any = None) -> Any

Get a setting value.

Parameters:

Name Type Description Default
key
str

The setting key (e.g., "theme/current").

required
default
Any

Default value if the key doesn't exist.

None

Returns:

Type Description
Any

The setting value, or the default if not found.

Examples:

>>> theme = fxconfig.get_value("theme/current", "dark")

set_application_name

set_application_name(name: str) -> None

Scope fxgui settings (including the persisted theme) to an application.

By default every tool built on fxgui shares one settings file, so e.g. changing the theme in one tool changes it for all of them. Calling this early in your application's startup isolates its settings in its own file:

  • Windows: %APPDATA%/<name>/settings.ini
  • Unix/macOS: ~/.<name>/settings.ini

Parameters:

Name Type Description Default
name
str

The application name to scope settings under. Must be a non-empty, filesystem-safe string.

required

Raises:

Type Description
ValueError

If the name is empty or contains path separators.

Examples:

>>> from fxgui import fxconfig
>>> fxconfig.set_application_name("my_studio_tool")

set_value

set_value(key: str, value: Any) -> None

Set a setting value.

The value is immediately synced to disk.

Parameters:

Name Type Description Default
key
str

The setting key (e.g., "theme/current").

required
value
Any

The value to store.

required

Examples:

>>> fxconfig.set_value("theme/current", "dracula")