| 237 | dc.DrawRectangle(round(max(padding - 1, 1)), 1, 1, round(rect.height)) |
| 238 | |
| 239 | def OnTimer(self, event): |
| 240 | old_value = self._old_percentage |
| 241 | value = self._percentage |
| 242 | start = 0 |
| 243 | |
| 244 | # -1 = left direction, 1 = right direction |
| 245 | direction = 1 if old_value < value else -1 |
| 246 | |
| 247 | end = direction * (value - old_value) |
| 248 | |
| 249 | self._anim_direction = direction |
| 250 | step = self.anim_effect(self._anim_step, start, end, self._anim_duration) |
| 251 | |
| 252 | self._anim_step += self._period |
| 253 | |
| 254 | if self._timer_id == event.GetId(): |
| 255 | stop_timer = False |
| 256 | |
| 257 | if self._anim_step > self._anim_duration: |
| 258 | stop_timer = True |
| 259 | |
| 260 | # add new value to the animation if we haven't reached our goal |
| 261 | # otherwise, stop animation |
| 262 | if direction == 1: |
| 263 | if old_value + step < value: |
| 264 | self._anim_value = old_value + step |
| 265 | else: |
| 266 | stop_timer = True |
| 267 | else: |
| 268 | if old_value - step > value: |
| 269 | self._anim_value = old_value - step |
| 270 | else: |
| 271 | stop_timer = True |
| 272 | |
| 273 | if stop_timer: |
| 274 | self._timer.Stop() |
| 275 | |
| 276 | self.Refresh() |