diff --git a/Packages/vcs/Lib/configurator.py b/Packages/vcs/Lib/configurator.py index 1c92a021e1..9fbd42e597 100644 --- a/Packages/vcs/Lib/configurator.py +++ b/Packages/vcs/Lib/configurator.py @@ -546,7 +546,9 @@ def setup_animation(self): self.anim_button = anim_toolbar.add_toggle_button("Animation", on=self.start_animating, off=self.stop_animating, on_prefix="Run", off_prefix="Stop") anim_toolbar.add_button(["Step Forward"], action=self.step_forward) anim_toolbar.add_button(["Step Backward"], action=self.step_back) - 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) + def get_frame(): + return self.canvas.animate.frame_num + anim_toolbar.add_slider_button(get_frame, 0, self.canvas.animate.number_of_frames(), "Time Slider", update=self.set_animation_frame) anim_toolbar.add_slider_button(self.animation_speed, 1, 30, "Frames Per Second", update=self.set_animation_speed) self.save_anim_button = anim_toolbar.add_button(["Save Animation", "Cancel Save"], action=self.save_animation_press) self.initialized = True @@ -641,11 +643,8 @@ def stop_animating(self): def set_animation_frame(self, value): value = int(value) - self.canvas.animate.draw_frame(value) + self.canvas.animate.draw_frame(value, allow_static=False, render_offscreen=False) return value - def final_animation_frame(self, value): - value = int(value) - self.canvas.animate.draw_frame(value, allow_static = False, render_offscreen = False) def set_background_red(self, value): _, g, b = self.canvas.backgroundcolor diff --git a/Packages/vcs/Lib/vtk_ui/slider.py b/Packages/vcs/Lib/vtk_ui/slider.py index 8c6f90a39a..4e746b35e9 100644 --- a/Packages/vcs/Lib/vtk_ui/slider.py +++ b/Packages/vcs/Lib/vtk_ui/slider.py @@ -35,7 +35,12 @@ def __init__(self, interactor, value=0, min_val=0, max_val=1, point1=(0,.1), poi self.repr.SetMinimumValue(float(min_val)) self.repr.SetMaximumValue(float(max_val)) - self.repr.SetValue(float(value)) + if callable(value): + self.repr.SetValue(float(value())) + self.value_func = value + else: + self.repr.SetValue(float(value)) + self.value_func = None self.repr.SetSliderLength(0.05) self.repr.SetSliderWidth(0.02) @@ -58,6 +63,8 @@ def place(self): self.repr.GetPoint2Coordinate().SetValue((self.x2, self.y2, 0)) def show(self): + if self.value_func: + self.repr.SetValue(float(self.value_func())) self.widget.EnabledOn() self.widget.On()