Skip to content

Commit

Permalink
Revert "delete autoclose function"
Browse files Browse the repository at this point in the history
This reverts commit 4b20e26.
  • Loading branch information
toruseo committed Mar 26, 2024
1 parent 4b20e26 commit 971d0d3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 11 additions & 1 deletion tests/test_result_gui_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,14 @@ def test_result_gui_viewer():
# Print summary of simulation result
W.analyzer.print_simple_stats()

ResultGUIViewer.launch_World_viewer(W)
app, window = ResultGUIViewer.launch_World_viewer(W, return_app_window=True)

# Shut down 5 sec later
from PyQt5.QtCore import QTimer
import sys
timer = QTimer()
timer.timeout.connect(window.close)
timer.start(1000*5)
assert True
with pytest.raises(SystemExit):
sys.exit(app.exec_())
4 changes: 3 additions & 1 deletion uxsim/ResultGUIViewer/ResultGUIViewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def toggle_show_vehicles(self):
self.show_vehicles = not self.show_vehicles
self.graph_widget.set_show_vehicles(self.show_vehicles)

def launch_World_viewer(W):
def launch_World_viewer(W, return_app_window=False):
"""
Launch the interactive viewer for the simulation result of the given World object.
Expand Down Expand Up @@ -419,6 +419,8 @@ def launch_World_viewer(W):
app = QApplication(sys.argv)
window = MainWindow(W, nodes, edges, vehicle_list, tmax)
window.show()
if return_app_window:
return app, window
sys.exit(app.exec_())


Expand Down

0 comments on commit 971d0d3

Please sign in to comment.