Mercurial > fife-parpg
comparison engine/extensions/pychan/attrs.py @ 123:ec653fde64d3
- modified pychan to accept r,g,b,a colors - default of a = 255, so you also just can use r, g, b
- examples:
- via XML: <ScrollArea background_color="0,0,0,100"> <VBox></VBox></ScrollArea>
- via python: my_scroll_area_widget.background_color = 0,0,0,100
author | chewie@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Tue, 05 Aug 2008 17:37:49 +0000 |
parents | 4a0efb7baf70 |
children | 9a1529f9625e |
comparison
equal
deleted
inserted
replaced
122:6b2f3a151f81 | 123:ec653fde64d3 |
---|---|
52 except: | 52 except: |
53 raise ParserError("Expected a comma separated list of two integers.") | 53 raise ParserError("Expected a comma separated list of two integers.") |
54 | 54 |
55 class ColorAttr(Attr): | 55 class ColorAttr(Attr): |
56 def parse(self,value): | 56 def parse(self,value): |
57 a = 255 | |
57 try: | 58 try: |
58 r,g,b = tuple(map(int,str(value).split(','))) | 59 try: |
60 r,g,b,a = tuple(map(int,str(value).split(','))) | |
61 for c in (r,g,b,a): | |
62 if not 0 <= c < 256: raise ParserError("Expected a color (Failed: 0 <= %d <= 255)" %c) | |
63 except: | |
64 r,g,b = tuple(map(int,str(value).split(','))) | |
65 for c in (r,g,b): | |
66 if not 0 <= c < 256: raise ParserError("Expected a color (Failed: 0 <= %d <= 255)" %c) | |
59 except: | 67 except: |
60 raise ParserError("Expected an color.") | 68 raise ParserError("Expected an color.") |
61 for c in (r,g,b): | 69 |
62 if not 0 <= c < 256: raise ParserError("Expected a color (Failed: 0 <= %d <= 255)" %c) | 70 return r,g,b,a |
63 return r,g,b | |
64 | 71 |
65 class IntAttr(Attr): | 72 class IntAttr(Attr): |
66 def parse(self,value): | 73 def parse(self,value): |
67 try: | 74 try: |
68 return int(value) | 75 return int(value) |