[MouseFox logo]
The MouseFox Project
Join The Community Discord Server
[Discord logo]
Edit on GitHub

kvex.assets

Assets utilities.

 1"""Assets utilities."""
 2
 3from pathlib import Path
 4
 5
 6ASSETS_DIR = Path(__file__).parent / "assets"
 7"""Assets directory."""
 8assert ASSETS_DIR.is_dir()
 9
10
11ALL_ASSETS: dict[str, Path] = dict()
12
13for file in ASSETS_DIR.iterdir():
14    if not file.is_file() or file.suffix != ".png":
15        continue
16    ALL_ASSETS[file.stem] = file
17
18
19IMAGES = tuple(ALL_ASSETS.keys())
20"""Image names."""
21
22
23def get_image(name: str, /) -> Path:
24    """Get an image path by name."""
25    return ALL_ASSETS[name]
26
27
28__all__ = (
29    "get_image",
30    "IMAGES",
31)
def get_image(name: str, /) -> pathlib.Path:
24def get_image(name: str, /) -> Path:
25    """Get an image path by name."""
26    return ALL_ASSETS[name]

Get an image path by name.

IMAGES = ('button', 'xframe_bg', 'button_down', 'spinner')

Image names.