MXVK Vulkan Framework 0.35.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
config.py
Go to the documentation of this file.
1## @file config.py
2## @brief Friendly persistent settings wrapper.
3
4from pathlib import Path
5
6from ._native import mxvk
7
8
9class Settings:
10 ## @brief A small INI-style MXVK settings file.
11
12 def __init__(self, path: str | Path | None = None) -> None:
13 ## @brief Create empty settings or load them from @p path.
14 self.native = mxvk.Config() if path is None else mxvk.Config(str(path))
15
16 def get(self, section: str, key: str, default: str = "") -> str:
17 ## @brief Return a setting, falling back to @p default when missing.
18 return self.native.item_at_key(section, key, default).value
19
20 def set(self, section: str, key: str, value: str) -> None:
21 ## @brief Store a string setting.
22 self.native.set_item(section, key, value)
23
24 def load(self, path: str | Path) -> None:
25 ## @brief Replace settings with the contents of @p path.
26 self.native.load_file(str(path))
27
28 def save(self, path: str | Path) -> None:
29 ## @brief Write settings to @p path.
30 self.native.save_file(str(path))
None __init__(self, str|Path|None path=None)
A small INI-style MXVK settings file.
Definition config.py:12
None set(self, str section, str key, str value)
Definition config.py:20
None load(self, str|Path path)
Definition config.py:24
str get(self, str section, str key, str default="")
Definition config.py:16
None save(self, str|Path path)
Definition config.py:28
native
Create empty settings or load them from path.
Definition config.py:14