import os
from eventutils import EventHandlerMixin, event_handler
from itertools import cycle
-from pygame.locals import MOUSEBUTTONDOWN, MOUSEBUTTONUP, USEREVENT
+from pygame.locals import USEREVENT
TIMEOUT = USEREVENT + 1
class WarpingCursor(pygame.sprite.Sprite, EventHandlerMixin):
def __init__(self, theme='black', duration=75, blink=True):
pygame.sprite.Sprite.__init__(self)
+ pygame.mouse.set_visible(False)
imagesPath, images = WarpingCursor._get_theme_images(theme)
flashImage = images.pop(images.index('flash.png'))
flashImagePath = os.path.sep.join([imagesPath, flashImage])
self.image = self.images[0]
self.rect = pygame.Rect((0,0), (self.width, self.height))
- self.update()
self.blink = blink
if blink :
def loadNext(self, event) :
if self.blink :
self.image = self.iterator.next()
- self.update()
- @event_handler(MOUSEBUTTONDOWN)
+ @event_handler(pygame.MOUSEBUTTONDOWN)
def flashOn(self, event) :
self.blink=False
self.image = self.flashImage
- self.update()
- @event_handler(MOUSEBUTTONUP)
+ @event_handler(pygame.MOUSEBUTTONUP)
def flashOff(self, event) :
self.blink = True
self.loadNext(event)
-
- def update(self) :
- surface = pygame.display.get_surface()
- surface.blit(self.image, self.rect)
+
+ @event_handler(pygame.MOUSEMOTION)
+ def move(self, event) :
+ x, y = event.rel
+ self.rect.centerx += x
+ self.rect.centery += y
+ #self.rect.move_ip(*rel)