-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
48 lines (34 loc) · 1.23 KB
/
Copy pathmain.py
File metadata and controls
48 lines (34 loc) · 1.23 KB
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 sys
import os
# Ensure the project root is on the path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from PyQt6.QtWidgets import QApplication
from PyQt6.QtCore import QSettings
from app.main_window import MainWindow
from app.theme import theme
from app.version import __version__
def _app_dir() -> str:
"""Return the directory that contains the running exe (frozen) or main.py."""
if getattr(sys, "frozen", False):
return os.path.dirname(sys.executable)
return os.path.dirname(os.path.abspath(__file__))
def main():
app = QApplication(sys.argv)
app.setOrganizationName("PatchToolPy")
app.setApplicationName("PatchTool")
app.setApplicationVersion(__version__)
# Store all settings as an ini file next to the exe/script
cache_dir = os.path.join(_app_dir(), "cache")
os.makedirs(cache_dir, exist_ok=True)
QSettings.setDefaultFormat(QSettings.Format.IniFormat)
QSettings.setPath(QSettings.Format.IniFormat, QSettings.Scope.UserScope, cache_dir)
theme.load_settings()
theme.apply(app)
window = MainWindow()
window.show()
sys.exit(app.exec())
window = MainWindow()
window.show()
sys.exit(app.exec())
if __name__ == "__main__":
main()