-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
54 lines (39 loc) · 1.24 KB
/
main.py
File metadata and controls
54 lines (39 loc) · 1.24 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
import sys
from PyQt6 import QtWidgets, QtGui
import os
from ui_nav import MainWindow
# --- Constants ---
APP_NAME = "SoilSight"
BASE_DIR = os.path.dirname(__file__)
LAYOUT_PATH = os.path.join(BASE_DIR, "mpcamera", "layouts", f"{APP_NAME}_MainWindow.ui")
ICON_PATH = os.path.join(BASE_DIR, "mpcamera", "assets", f"{APP_NAME}_Logo.ico")
def setup_application_properties(app: QtWidgets.QApplication):
"""Sets application-wide properties like style and icon."""
try:
app.setStyle("Fusion")
except Exception:
pass
app.setApplicationName(APP_NAME)
try:
app.setApplicationDisplayName(APP_NAME)
except Exception:
pass
if os.path.exists(ICON_PATH):
try:
app.setWindowIcon(QtGui.QIcon(ICON_PATH))
except Exception as e:
print(f"Warning: Failed to set application icon. Error: {e}")
def main():
app = QtWidgets.QApplication(sys.argv)
setup_application_properties(app)
win = MainWindow(LAYOUT_PATH)
win.setWindowTitle(APP_NAME)
if os.path.exists(ICON_PATH):
try:
win.setWindowIcon(QtGui.QIcon(ICON_PATH))
except Exception:
pass
win.show()
sys.exit(app.exec())
if __name__ == "__main__":
main()