comparison pyntnclick/widgets/text.py @ 813:3a875256f795 pyntnclick

better visible handling
author Neil Muller <neil@dip.sun.ac.za>
date Sun, 27 Jan 2013 17:33:04 +0200
parents bcc9277a23e6
children 9f542ef6e498
comparison
equal deleted inserted replaced
812:2dd400a7c16d 813:3a875256f795
13 self.text = text 13 self.text = text
14 constants = self.gd.constants 14 constants = self.gd.constants
15 self.fontname = fontname or constants.font 15 self.fontname = fontname or constants.font
16 self.fontsize = fontsize or constants.font_size 16 self.fontsize = fontsize or constants.font_size
17 self.color = color or constants.text_color 17 self.color = color or constants.text_color
18 self.visible = True
19 18
20 def prepare(self): 19 def prepare(self):
21 self.font = self.resource.get_font(self.fontname, self.fontsize) 20 self.font = self.resource.get_font(self.fontname, self.fontsize)
22 self.color = convert_color(self.color) 21 self.color = convert_color(self.color)
23 self.surface = self.font.render(self.text, True, self.color) 22 self.surface = self.font.render(self.text, True, self.color)
57 new_surface.get_rect(), 56 new_surface.get_rect(),
58 self.border) 57 self.border)
59 self.surface = new_surface 58 self.surface = new_surface
60 59
61 def draw(self, surface): 60 def draw(self, surface):
62 self.do_prepare() 61 if self.visible:
63 surface.blit(self.surface, self.rect) 62 self.do_prepare()
63 surface.blit(self.surface, self.rect)
64 64
65 65
66 class TextButton(Button, TextWidget): 66 class TextButton(Button, TextWidget):
67 def __init__(self, pos, gd, *args, **kwargs): 67 def __init__(self, pos, gd, *args, **kwargs):
68 constants = gd.constants 68 constants = gd.constants