-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAstroImageLab.py
More file actions
75 lines (65 loc) · 2.69 KB
/
Copy pathAstroImageLab.py
File metadata and controls
75 lines (65 loc) · 2.69 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
68
69
70
71
72
73
74
75
#build with: conda run -n astrolab pyinstaller --clean AstroImageLab.spec
#
# build the local environment: conda env create -f d:\GitHub\AstroImageLab\environment.yml
#
# PR → merge to main (CI runs tests + build to verify everything works)
# Tag the merge commit on main → triggers the release workflow
# git tag v0.0.11
# git push origin v0.0.11
import sys
import os
# Prepend PyQt6's own Qt6 bin directory to PATH so Windows finds the correct Qt6
# DLLs before any conflicting copies installed by other programs (e.g. MiKTeX).
# This must happen before any PyQt6 import.
if not getattr(sys, "frozen", False):
import importlib.util
_spec = importlib.util.find_spec("PyQt6")
if _spec and _spec.submodule_search_locations:
_qt_bin = os.path.join(list(_spec.submodule_search_locations)[0], "Qt6", "bin")
if os.path.isdir(_qt_bin):
os.environ["PATH"] = _qt_bin + os.pathsep + os.environ.get("PATH", "")
import time
from PyQt6.QtWidgets import QApplication, QSplashScreen
from PyQt6.QtGui import QIcon, QPixmap
from PyQt6.QtCore import Qt, QTimer
from gui.main_window import MainWindow
from core.models import SPLASH_DURATION_MS
def _load_splash_pixmap() -> QPixmap:
splash_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
"resources", "AstroImageLabSplash.png")
pix = QPixmap(splash_path)
if not pix.isNull():
pix = pix.scaledToWidth(640, Qt.TransformationMode.SmoothTransformation)
return pix
if __name__ == "__main__":
app = QApplication(sys.argv)
app.setApplicationName("Astro Image Lab")
# Application icon
_icon_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
"resources", "icon.ico")
if os.path.exists(_icon_path):
app.setWindowIcon(QIcon(_icon_path))
# Splash screen
splash = QSplashScreen(_load_splash_pixmap(),
Qt.WindowType.WindowStaysOnTopHint)
splash.show()
app.processEvents()
# Explicit tooltip colours so they remain readable in both dark and light mode.
# Qt inherits tooltip colours from the system palette; on Windows dark mode the
# default produces dark-grey text on a dark-grey background.
app.setStyleSheet("""
QToolTip {
background-color: #1e1e1e;
color: #f0f0f0;
border: 1px solid #555555;
padding: 4px 6px;
border-radius: 3px;
font-size: 9pt;
}
""")
t_start = time.monotonic()
window = MainWindow()
window.show()
elapsed_ms = int((time.monotonic() - t_start) * 1000)
QTimer.singleShot(max(0, SPLASH_DURATION_MS - elapsed_ms), splash.close)
sys.exit(app.exec())