Skip to content

Commit bb21d5c

Browse files
committed
new main to run tests in workflow.
1 parent 8bb3b9f commit bb21d5c

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

main.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
import logging
22
import sys
3+
import os
34
from PyQt6.QtWidgets import QApplication
5+
from PyQt6.QtCore import QTimer
46

57
from src.models.barrier_tool_model import BarrierToolModel
68
from src.presenters.barrier_tool_presenter import BarrierToolPresenter
79
from src.views.barrier_tool_view import BarrierToolView
8-
910
from src.utils.logging import setup_logging
1011

11-
if __name__ == "__main__":
12-
# Setup logging. Possible values: logging.DEBUG, logging.INFO:
12+
13+
def launch_app(auto_close=False):
14+
"""
15+
Launch the Barrier Tool GUI.
16+
17+
:param auto_close: If True, closes the GUI automatically after 1 second (for testing).
18+
:return: exit code of the QApplication
19+
"""
20+
# Setup logging
1321
setup_logging(logging.INFO)
1422

1523
app = QApplication(sys.argv)
@@ -19,4 +27,18 @@
1927
presenter = BarrierToolPresenter(model, view)
2028

2129
presenter.show()
22-
sys.exit(app.exec())
30+
31+
# Auto-close if testing
32+
if auto_close or os.getenv("AUTO_CLOSE_GUI") == "1":
33+
QTimer.singleShot(1000, app.quit) # quit after 1 second
34+
35+
return app.exec()
36+
37+
38+
def main():
39+
exit_code = launch_app()
40+
sys.exit(exit_code)
41+
42+
43+
if __name__ == "__main__":
44+
main()
File renamed without changes.

0 commit comments

Comments
 (0)