X-Git-Url: https://scm.cri.mines-paristech.fr/git/minwii.git/blobdiff_plain/a1cb64098e2a34d115378fdced1044da37e94395..7d014e3dc9f077f1b0402aed8f957146bf317ea7:/src/app/widgets/cursors.py diff --git a/src/app/widgets/cursors.py b/src/app/widgets/cursors.py index 6d81a67..b52bfb3 100755 --- a/src/app/widgets/cursors.py +++ b/src/app/widgets/cursors.py @@ -8,9 +8,12 @@ $URL$ import pygame import os +from eventutils import EventHandlerMixin, event_handler +from itertools import cycle +from pygame.locals import USEREVENT +TIMEOUT = USEREVENT + 1 - -class WarpingCursor(pygame.sprite.Sprite): +class WarpingCursor(pygame.sprite.Sprite, EventHandlerMixin): ''' The class for animating the warping cursor @@ -63,6 +66,7 @@ class WarpingCursor(pygame.sprite.Sprite): surface = pygame.display.get_surface() surface.blit(self.image, self.rect) + self._startBlink() #self.flashImagePath = flashImage #self.durations = durations @@ -73,6 +77,20 @@ class WarpingCursor(pygame.sprite.Sprite): #self._imagePointer = 0 #self._animationOffset = 0 #self._flashTimer = 0 + + def _startBlink(self) : + pygame.time.set_timer(TIMEOUT, self.duration) + self.iterator = self.iterImages() + + def iterImages(self) : + for img in cycle(self.images) : + yield img + + @event_handler(TIMEOUT) + def loadNext(self, event) : + self.image = self.iterator.next() + surface = pygame.display.get_surface() + surface.blit(self.image, self.rect) def update(self) : print 'cursor update'