@@ -105,7 +105,7 @@ def __init__(
105
105
"Simulation status" , QIcon ("img:in_progress.svg" )
106
106
)
107
107
self .results_button .setEnabled (False )
108
- self .results_button . setMenu ( QMenu ())
108
+ self .run_dialog_counter = 0
109
109
110
110
self .vbox_layout .addStretch ()
111
111
self .central_layout .addWidget (self .side_frame )
@@ -126,6 +126,13 @@ def select_central_widget(self):
126
126
self .central_layout .addWidget (self ._plot_window )
127
127
self .central_panels_map ["Create plot" ] = self ._plot_window
128
128
129
+ if index_name == "Simulation status" :
130
+ # select the only available simulation
131
+ for k , v in self .central_panels_map .items ():
132
+ if isinstance (v , RunDialog ):
133
+ index_name = k
134
+ break
135
+
129
136
for i , widget in self .central_panels_map .items ():
130
137
widget .setVisible (i == index_name )
131
138
@@ -135,16 +142,30 @@ def slot_add_widget(self, run_dialog: RunDialog) -> None:
135
142
widget .setVisible (False )
136
143
137
144
run_dialog .setParent (self )
138
- self .central_layout .addWidget (run_dialog )
139
- self .results_button .setEnabled (True )
140
- date_time = datetime .datetime .utcnow ().strftime ("%Y-%d-%m %H:%M:%S" )
145
+ date_time = datetime .datetime .now (datetime .UTC ).strftime ("%Y-%d-%m %H:%M:%S" )
141
146
self .central_panels_map [date_time ] = run_dialog
142
- act = self .results_button .menu ()
147
+ self .run_dialog_counter += 1
148
+ self .central_layout .addWidget (run_dialog )
143
149
144
- if act :
145
- act .addAction (date_time )
146
- act .setProperty ("index" , date_time )
147
- act .triggered .connect (self .select_central_widget )
150
+ def add_sim_run_option (datetime : str ) -> None :
151
+ menu = self .results_button .menu ()
152
+ if menu :
153
+ act = menu .addAction (datetime )
154
+ act .setProperty ("index" , datetime )
155
+ act .triggered .connect (self .select_central_widget )
156
+
157
+ if self .run_dialog_counter == 2 :
158
+ # swap from button to menu selection
159
+ self .results_button .clicked .disconnect (self .select_central_widget )
160
+ self .results_button .setMenu (QMenu ())
161
+
162
+ for prev_date_time , widget in self .central_panels_map .items ():
163
+ if isinstance (widget , RunDialog ):
164
+ add_sim_run_option (prev_date_time )
165
+ elif self .run_dialog_counter > 2 :
166
+ add_sim_run_option (date_time )
167
+
168
+ self .results_button .setEnabled (True )
148
169
149
170
def post_init (self ) -> None :
150
171
experiment_panel = ExperimentPanel (
0 commit comments