MCPcopy Create free account
hub / github.com/pyfa-org/Pyfa / OnTimer

Method OnTimer

gui/pyfa_gauge.py:359–396  ·  view source on GitHub ↗
(self, event)

Source from the content-addressed store, hash-verified

357 dc.DrawLabel(format_.format(value), rect, wx.ALIGN_CENTER)
358
359 def OnTimer(self, event):
360 old_value = self._old_percentage
361 value = self._percentage
362 start = 0
363
364 # -1 = left direction, 1 = right direction
365 direction = 1 if old_value < value else -1
366
367 end = direction * (value - old_value)
368
369 self._anim_direction = direction
370 step = self.anim_effect(self._anim_step, start, end, self._anim_duration)
371
372 self._anim_step += self._period
373
374 if self._timer_id == event.GetId():
375 stop_timer = False
376
377 if self._anim_step > self._anim_duration:
378 stop_timer = True
379
380 # add new value to the animation if we haven't reached our goal
381 # otherwise, stop animation
382 if direction == 1:
383 if old_value + step < value:
384 self._anim_value = old_value + step
385 else:
386 stop_timer = True
387 else:
388 if old_value - step > value:
389 self._anim_value = old_value - step
390 else:
391 stop_timer = True
392
393 if stop_timer:
394 self._timer.Stop()
395
396 self.Refresh()

Callers

nothing calls this directly

Calls 2

StopMethod · 0.80
RefreshMethod · 0.45

Tested by

no test coverage detected