Skip to content

Commit

Permalink
initialize in the timer callback
Browse files Browse the repository at this point in the history
  • Loading branch information
skoudoro committed Feb 21, 2023
1 parent bf311f4 commit f3ffc40
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/tutorials/01_introductory/viz_timers.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ def timer_callback(_obj, _event):
# Run every 200 milliseconds
timer_id = showm.add_timer_callback(True, 200, timer_callback)

showm.start(keep_alive=True)
showm.start()

showm.record(size=(900, 768), out_path='viz_timer.png')
4 changes: 2 additions & 2 deletions fury/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,6 @@ def start(self, multithreaded=False, desired_fps=60):
if end_time - start_time < time_per_frame:
time.sleep(time_per_frame - (end_time - start_time))
else:
if not self.iren.GetInitialized():
self.initialize()
self.render()
self.iren.Start()

Expand Down Expand Up @@ -744,6 +742,8 @@ def add_window_callback(self, win_callback, event=Command.ModifiedEvent):
self.window.Render()

def add_timer_callback(self, repeat, duration, timer_callback):
if not self.iren.GetInitialized():
self.initialize()
self.iren.AddObserver('TimerEvent', timer_callback)

if repeat:
Expand Down

0 comments on commit f3ffc40

Please sign in to comment.