Line data Source code
1 : # SPDX-FileCopyrightText: 2025 PairInteraction Developers
2 : # SPDX-License-Identifier: LGPL-3.0-or-later
3 :
4 :
5 1 : import os
6 1 : import sys
7 :
8 1 : from PySide6.QtCore import QLoggingCategory, QTimer
9 :
10 1 : from pairinteraction_gui.app import Application, SplashScreen
11 :
12 1 : __all__ = ["main"]
13 :
14 :
15 1 : def main(*, enable_theme_hot_reload: bool = False) -> int:
16 : """Run the PairInteraction GUI application.
17 :
18 : Returns:
19 : int: Application exit code
20 :
21 : """
22 0 : rules = os.environ.get("QT_LOGGING_RULES", "")
23 0 : if "qt.gui.icc.warning=" not in rules:
24 0 : QLoggingCategory.setFilterRules(f"{rules}\nqt.gui.icc.warning=false".strip())
25 :
26 0 : app = Application(sys.argv)
27 0 : app.setApplicationName("PairInteraction")
28 0 : app.allow_ctrl_c()
29 :
30 0 : splash = SplashScreen()
31 0 : splash.show()
32 0 : app.processEvents()
33 :
34 0 : def _start() -> None:
35 0 : from pairinteraction_gui.main_window import MainWindow
36 :
37 0 : window = MainWindow(enable_theme_hot_reload=enable_theme_hot_reload)
38 0 : window.show()
39 0 : app.processEvents()
40 0 : QTimer.singleShot(0, lambda: splash.finish(window))
41 :
42 : # 50 ms lets the compositor flush the first frame, avoiding painting issues with the splash screen on some platforms
43 0 : QTimer.singleShot(50, _start)
44 :
45 0 : return app.exec()
|