Mercurial > pyntnclick
comparison pyntnclick/widgets/base.py @ 824:9f542ef6e498 pyntnclick
Reorganise code
author | Neil Muller <neil@dip.sun.ac.za> |
---|---|
date | Tue, 29 Jan 2013 11:41:03 +0200 |
parents | 3a875256f795 |
children | 547021cd0afa |
comparison
equal
deleted
inserted
replaced
823:1bf088e7865b | 824:9f542ef6e498 |
---|---|
4 from pygame.locals import (MOUSEBUTTONDOWN, MOUSEBUTTONUP, | 4 from pygame.locals import (MOUSEBUTTONDOWN, MOUSEBUTTONUP, |
5 MOUSEMOTION, SRCALPHA, USEREVENT, | 5 MOUSEMOTION, SRCALPHA, USEREVENT, |
6 BLEND_RGBA_MIN) | 6 BLEND_RGBA_MIN) |
7 | 7 |
8 from pyntnclick.engine import UserEvent | 8 from pyntnclick.engine import UserEvent |
9 from pyntnclick.utils import convert_color | |
9 | 10 |
10 | 11 |
11 class Widget(object): | 12 class Widget(object): |
12 | 13 |
13 highlight_cursor = False | 14 highlight_cursor = False |
216 background.fill(pygame.Color('gray')) | 217 background.fill(pygame.Color('gray')) |
217 surface.blit(background, self.rect) | 218 surface.blit(background, self.rect) |
218 super(Box, self).draw(surface) | 219 super(Box, self).draw(surface) |
219 | 220 |
220 | 221 |
221 def convert_color(color): | |
222 """Give me a pygame Color, dammit""" | |
223 if isinstance(color, pygame.Color): | |
224 return color | |
225 if isinstance(color, basestring): | |
226 return pygame.Color(color) | |
227 return pygame.Color(*color) | |
228 | |
229 | |
230 class ModalWrapper(Container): | 222 class ModalWrapper(Container): |
231 "A wrapper around a widget that removes itself when a mouse click occurs" | 223 "A wrapper around a widget that removes itself when a mouse click occurs" |
232 | 224 |
233 def __init__(self, widget, close_callback=None): | 225 def __init__(self, widget, close_callback=None): |
234 super(ModalWrapper, self).__init__(widget.rect.topleft, widget.gd, | 226 super(ModalWrapper, self).__init__(widget.rect.topleft, widget.gd, |