-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
67 lines (53 loc) · 2.21 KB
/
Copy pathmain.py
File metadata and controls
67 lines (53 loc) · 2.21 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"""SerialLink Doctor — portable COM/serial diagnostic tool.
Usage: python main.py (run normally)
pyinstaller main.spec (build EXE)
"""
from __future__ import annotations
import sys
import os
# Ensure app package is importable when running from source
_here = os.path.dirname(os.path.abspath(__file__))
if _here not in sys.path:
sys.path.insert(0, _here)
from PySide6.QtWidgets import QApplication
from app.main_window import MainWindow
from app.theme import STYLESHEET
def _resolve(path: str) -> str:
"""Resolve *path* for dev runs and PyInstaller onefile builds."""
if getattr(sys, "frozen", False):
# noinspection PyProtectedMember
return os.path.join(getattr(sys, "_MEIPASS", ""), path)
return os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
def main():
# Qt 6 enables high-DPI by default — no manual attribute needed.
app = QApplication(sys.argv)
app.setApplicationName("SerialLink Doctor")
app.setOrganizationName("SerialLinkDoctor")
app.setStyleSheet(STYLESHEET)
# Window / taskbar icon
from PySide6.QtGui import QIcon
icon_path = _resolve("icon.png")
icon = QIcon(icon_path)
app.setWindowIcon(icon)
# Apply dark palette as fallback
from PySide6.QtGui import QPalette, QColor
p = app.palette()
p.setColor(QPalette.ColorRole.Window, QColor("#1a1d25"))
p.setColor(QPalette.ColorRole.WindowText, QColor("#e2e4ea"))
p.setColor(QPalette.ColorRole.Base, QColor("#111318"))
p.setColor(QPalette.ColorRole.AlternateBase, QColor("#21242e"))
p.setColor(QPalette.ColorRole.ToolTipBase, QColor("#282c38"))
p.setColor(QPalette.ColorRole.ToolTipText, QColor("#e2e4ea"))
p.setColor(QPalette.ColorRole.Text, QColor("#e2e4ea"))
p.setColor(QPalette.ColorRole.Button, QColor("#282c38"))
p.setColor(QPalette.ColorRole.ButtonText, QColor("#e2e4ea"))
p.setColor(QPalette.ColorRole.BrightText, QColor("#00d4aa"))
p.setColor(QPalette.ColorRole.Highlight, QColor("#00d4aa"))
p.setColor(QPalette.ColorRole.HighlightedText, QColor("#111318"))
app.setPalette(p)
window = MainWindow()
window.setWindowIcon(icon)
window.show()
sys.exit(app.exec())
if __name__ == "__main__":
main()