Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/sugar/graphics/xocolor.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/sugar/graphics/xocolor.py b/src/sugar/graphics/xocolor.py
index 92a61a4..00238d9 100644
--- a/src/sugar/graphics/xocolor.py
+++ b/src/sugar/graphics/xocolor.py
@@ -20,6 +20,7 @@ STABLE.
"""
import random
+import logging
colors = [
['#B20008', '#FF2B34'], \
@@ -225,7 +226,16 @@ def is_valid(color_string):
class XoColor:
def __init__(self, color_string=None):
- if color_string == None or not is_valid(color_string):
+ if color_string == None:
+ randomize = True
+ elif not is_valid(color_string):
+ logging.error('Color string is not valid: %s, will generate a '
+ 'random color pair.', color_string)
+ randomize = True
+ else:
+ randomize = False
+
+ if randomize:
n = int(random.random() * (len(colors) - 1))
[self.stroke, self.fill] = colors[n]
else: