-
-
Notifications
You must be signed in to change notification settings - Fork 98
/
main.py
48 lines (40 loc) · 1.13 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import os.path
import sys
import json
from PySide6 import QtWidgets
from qt_material import apply_stylesheet
from main_ui_files.MainWindow import MainWindow
def CreateConfig():
config = {
"theme": {
"location": os.path.join("css", "themes", "dark_teal.xml"),
"is_light": False,
}
}
fp = open("config.json", "w")
json.dump(config, fp=fp, indent=4)
fp.close()
return config
def main() -> None:
if os.path.exists("config.json"):
try:
with open("config.json", "r") as f:
config = json.load(f)
except json.decoder.JSONDecodeError:
print("Could not load config. Recreating...")
config = CreateConfig()
else:
config = CreateConfig()
app = QtWidgets.QApplication(sys.argv)
if config["theme"]["location"]:
apply_stylesheet(
app,
theme=config["theme"]["location"],
invert_secondary=config["theme"]["is_light"],
)
window = MainWindow(app)
window.setWindowTitle("LoRA Trainer")
window.show()
app.exec()
if __name__ == "__main__":
main()