2022-02-23 00:38:40 +03:00
|
|
|
import sys
|
2022-02-28 02:35:52 +03:00
|
|
|
import os
|
|
|
|
import json
|
2022-02-23 00:38:40 +03:00
|
|
|
|
|
|
|
|
2022-05-17 22:44:59 +03:00
|
|
|
class ThemeManager:
|
2022-02-23 00:38:40 +03:00
|
|
|
|
2022-02-28 02:35:52 +03:00
|
|
|
theme = {} # contains all the theme data
|
2022-05-09 22:50:54 +03:00
|
|
|
built_in_themes = ["blue", "green", "dark-blue", "sweetkind"]
|
2022-02-28 02:35:52 +03:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def load_theme(cls, theme_name_or_path: str):
|
|
|
|
script_directory = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
|
|
|
|
if theme_name_or_path in cls.built_in_themes:
|
2022-10-29 14:11:55 +03:00
|
|
|
with open(os.path.join(script_directory, "../../../assets", "themes", f"{theme_name_or_path}.json"), "r") as f:
|
2022-02-28 02:35:52 +03:00
|
|
|
cls.theme = json.load(f)
|
|
|
|
else:
|
|
|
|
with open(theme_name_or_path, "r") as f:
|
|
|
|
cls.theme = json.load(f)
|
|
|
|
|
|
|
|
if sys.platform == "darwin":
|
|
|
|
cls.theme["text"] = cls.theme["text"]["macOS"]
|
|
|
|
elif sys.platform.startswith("win"):
|
|
|
|
cls.theme["text"] = cls.theme["text"]["Windows"]
|
|
|
|
else:
|
|
|
|
cls.theme["text"] = cls.theme["text"]["Linux"]
|