Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2011-02-27 21:54:57 (GMT)
committer Walter Bender <walter.bender@gmail.com>2011-02-27 21:54:57 (GMT)
commit82ab0c3f73213e82ca94c08c26da2ffa7556e55b (patch)
tree569dbc8dc9dc8e07c680c63810f99a6c28e9f221
parent4ea385af0409c75f590ce7c97aefa98e56f8432c (diff)
add class for adding palettes
-rw-r--r--TurtleArt/taprimitive.py36
1 files changed, 35 insertions, 1 deletions
diff --git a/TurtleArt/taprimitive.py b/TurtleArt/taprimitive.py
index 4abc54f..4be5172 100644
--- a/TurtleArt/taprimitive.py
+++ b/TurtleArt/taprimitive.py
@@ -20,11 +20,45 @@
#THE SOFTWARE.
from taconstants import BLOCK_STYLES, BLOCK_NAMES, HELP_STRINGS, PALETTES, \
- PALETTE_NAMES, CONTENT_BLOCKS, PRIMITIVES, DEFAULTS, SPECIAL_NAMES
+ PALETTE_NAMES, CONTENT_BLOCKS, PRIMITIVES, DEFAULTS, SPECIAL_NAMES, \
+ COLORS
from talogo import VALUE_BLOCKS
from tautils import debug_output
+class Palette():
+ """ a class for defining new palettes """
+
+ def __init__(self, name, colors=["#00FF00", "#00A000"]):
+ self._name = name
+ self._colors = colors
+ self._help = None
+
+ def add_palette(self):
+ if self._name is None:
+ debug_output('You must specify a name for your palette')
+ return
+
+ # Insert new palette just before the trash
+ if 'trash' in PALETTE_NAMES:
+ i = PALETTE_NAMES.index('trash')
+ else:
+ i = len(PALETTE_NAMES)
+ PALETTE_NAMES.insert(i, self._name)
+ PALETTES.insert(i, [])
+ COLORS.insert(i, self._colors)
+
+ # Special name entry is needed for help hover mechanism
+ SPECIAL_NAMES[self._name] = self._name
+ if self._help is not None:
+ HELP_STRINGS[self._name] = self._help
+ else:
+ HELP_STRINGS[self._name] = ''
+
+ def set_help(self, help):
+ self._help = help
+
+
class Primitive():
""" a class for defining new block primitives """