@@ -164,6 +164,7 @@ def __init__(self, canvas):
164164 self .save_timer = None
165165 self .save_listener = None
166166 self .save_anim_button = None
167+ self .anim_button = None
167168 self .listeners = []
168169 self .animation_last_frame_time = datetime .datetime .now ()
169170 # Map custom templates to their source template
@@ -542,7 +543,7 @@ def setup_animation(self):
542543 if self .initialized == False :
543544 self .canvas .animate .create ()
544545 anim_toolbar = self .toolbar .add_toolbar ("Animation" )
545- anim_toolbar .add_toggle_button ("Animation" , on = self .start_animating , off = self .stop_animating , on_prefix = "Run" , off_prefix = "Stop" )
546+ self . anim_button = anim_toolbar .add_toggle_button ("Animation" , on = self .start_animating , off = self .stop_animating , on_prefix = "Run" , off_prefix = "Stop" )
546547 anim_toolbar .add_button (["Step Forward" ], action = self .step_forward )
547548 anim_toolbar .add_button (["Step Backward" ], action = self .step_back )
548549 anim_toolbar .add_slider_button (0 , 0 , self .canvas .animate .number_of_frames (), "Time Slider" , update = self .set_animation_frame , end = self .final_animation_frame )
@@ -558,6 +559,9 @@ def step_back(self, state):
558559
559560 def save_animation_press (self , state ):
560561 if state == 1 :
562+ if self .animation_timer :
563+ self .stop_animating ()
564+ self .anim_button .set_state (0 )
561565 self .save_listener = self .interactor .AddObserver ("TimerEvent" , self .save_tick )
562566 self .save_timer = self .interactor .CreateRepeatingTimer (10 )
563567 else :
@@ -624,7 +628,7 @@ def set_animation_speed(self, value):
624628 def animate (self , obj , event ):
625629 if self .animation_timer is not None and datetime .datetime .now () - self .animation_last_frame_time > datetime .timedelta (0 , 0 , 0 , int (.9 * 1000. / self .animation_speed )):
626630 self .animation_last_frame_time = datetime .datetime .now ()
627- self .canvas .animate .draw_frame ((self .canvas .animate .frame_num + 1 ) % self .canvas .animate .number_of_frames ())
631+ self .canvas .animate .draw_frame ((self .canvas .animate .frame_num + 1 ) % self .canvas .animate .number_of_frames (), render_offscreen = False , allow_static = False )
628632
629633 def start_animating (self ):
630634 if self .animation_timer is None :
@@ -634,7 +638,6 @@ def stop_animating(self):
634638 if self .animation_timer is not None :
635639 t , self .animation_timer = self .animation_timer , None
636640 self .interactor .DestroyTimer (t )
637- self .canvas .animate .draw_frame (allow_static = False , render_offscreen = False )
638641
639642 def set_animation_frame (self , value ):
640643 value = int (value )
0 commit comments