main logo
Subject: [dabo-dev] dabo Commit 1081
Author: Ed Leafe
Posted: 2005/07/31 21:06:00
 
View Entire Thread
New Search


dabo Commit
Revision 1081
Date: 2005-07-31 19:11:14 -0700 (Sun, 31 Jul 2005)
Author: ed

Changed:
U trunk/common/dColors.py
U trunk/ui/uiwx/dPemMixin.py

Log:
Added some additional color-resolution code. This change allows passing a string representation of a color tuple, such as is returned from XML, and converting it to the actual tuple of values.



Diff:
Modified: trunk/common/dColors.py
===================================================================
--- trunk/common/dColors.py 2005-07-30 22:43:38 UTC (rev 1080)
+++ trunk/common/dColors.py 2005-08-01 02:11:14 UTC (rev 1081)
@@ -1,3 +1,5 @@
+import re
+
colorDict = {"aliceblue" : (240, 248, 255),
"antiquewhite" : (250, 235, 215),
"aqua" : (0, 255, 255),
@@ -197,6 +199,16 @@
try:
return colorDict[color.lower().strip()]
except KeyError:
+ return colorTupleFromString(color)
+
+
+def colorTupleFromString(color):
+ colorTuplePat = "\((\d+), *(\d+), *(\d+)\)"
+ mtch = re.match(colorTuplePat, color)
+ if mtch:
+ grps = mtch.groups()
+ ret = (int(grps[0]), int(grps[1]), int(grps[2]))
+ else:
raise KeyError, "Color '%s' is not defined." % color



Modified: trunk/ui/uiwx/dPemMixin.py
===================================================================
--- trunk/ui/uiwx/dPemMixin.py 2005-07-30 22:43:38 UTC (rev 1080)
+++ trunk/ui/uiwx/dPemMixin.py 2005-08-01 02:11:14 UTC (rev 1081)
@@ -692,9 +692,10 @@
try:
val = dColors.colorTupleFromName(val)
except: pass
- self.SetBackgroundColour(val)
- # Background color changes don't result in an automatic refresh.
- self.Refresh()
+ if isinstance(val, tuple):
+ self.SetBackgroundColour(val)
+ # Background color changes don't result in an automatic refresh.
+ self.Refresh()
else:
self._properties["BackColor"] = val






 
©2005 Ed Leafe
<-- Prior Message New Search Next Message -->