Mercurial > fife-parpg
changeset 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 | 6b2f3a151f81 |
children | d5658e6c34f5 |
files | engine/extensions/pychan/attrs.py |
diffstat | 1 files changed, 11 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/engine/extensions/pychan/attrs.py Tue Aug 05 14:56:54 2008 +0000 +++ b/engine/extensions/pychan/attrs.py Tue Aug 05 17:37:49 2008 +0000 @@ -54,13 +54,20 @@ class ColorAttr(Attr): def parse(self,value): + a = 255 try: - r,g,b = tuple(map(int,str(value).split(','))) + try: + r,g,b,a = tuple(map(int,str(value).split(','))) + for c in (r,g,b,a): + if not 0 <= c < 256: raise ParserError("Expected a color (Failed: 0 <= %d <= 255)" %c) + except: + r,g,b = tuple(map(int,str(value).split(','))) + for c in (r,g,b): + if not 0 <= c < 256: raise ParserError("Expected a color (Failed: 0 <= %d <= 255)" %c) except: raise ParserError("Expected an color.") - for c in (r,g,b): - if not 0 <= c < 256: raise ParserError("Expected a color (Failed: 0 <= %d <= 255)" %c) - return r,g,b + + return r,g,b,a class IntAttr(Attr): def parse(self,value):