@@ -488,6 +488,9 @@ def __init__(self, argv):
488488 # CYCLE_TIME = time, in milliseconds, that display will sleep between polls
489489 cycle_time = self .get_ini_info .get_cycle_time ()
490490 GLib .timeout_add ( cycle_time , self ._periodic ) # time between calls to the function, in milliseconds
491+ GLib .timeout_add (1000 , self ._periodic_1s ) # 1 s timer for elapsed time display
492+ self .elapsed_time_run = 0
493+ self .progress = 0
491494
492495 # This allows sourcing an user defined file
493496 rcfile = "~/.gmoccapyrc"
@@ -2424,6 +2427,14 @@ def _periodic(self):
24242427 # keep the timer running
24252428 return True
24262429
2430+ # every 1 second this gets called
2431+ def _periodic_1s (self ):
2432+ if hal .get_value ('halui.program.is-running' ):
2433+ self .elapsed_time_run += 1
2434+ self ._update_progressbar_text ()
2435+ return True
2436+
2437+
24272438 def _show_error (self , error ):
24282439 kind , text = error
24292440 # print(kind,text)
@@ -2576,9 +2587,13 @@ def on_hal_status_line_changed(self, widget, line):
25762587
25772588 # The program length used for the progress calculation is decreased here by 1 because
25782589 # the last line doesn't emit a line-changed signal.
2579- progress = line / (self .halcomp ["program.length" ]- 1 )
2580- if progress > 1.0 : progress = 1.0
2581- self .widgets .progressbar_pgm .set_fraction (progress )
2590+ self .progress = line / (self .halcomp ["program.length" ]- 1 )
2591+ if self .progress > 1.0 : self .progress = 1.0
2592+ self .widgets .progressbar_pgm .set_fraction (self .progress )
2593+ self ._update_progressbar_text ()
2594+
2595+ def _update_progressbar_text (self ):
2596+ self .widgets .progressbar_pgm .set_text (f"{ self .progress * 100 :.0f} % ({ self .seconds_to_hms (self .elapsed_time_run )} )" )
25822597
25832598 def on_hal_status_interp_idle (self , widget ):
25842599 LOG .debug ("IDLE" )
@@ -2650,6 +2665,7 @@ def on_hal_status_interp_run(self, widget):
26502665
26512666 self ._change_kbd_image ("img_macro_menu_stop" )
26522667 self .macro_dic ["keyboard" ].set_sensitive (True )
2668+ self .elapsed_time_run = 0
26532669
26542670 def on_hal_status_tool_in_spindle_changed (self , object , new_tool_no ):
26552671 LOG .debug ("hal signal tool changed" )
0 commit comments