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-04-08 19:21:30 (GMT)
committer Walter Bender <walter.bender@gmail.com>2011-04-08 19:21:30 (GMT)
commit3aeffe42ac7268c7bcf703e16fa9413a06dd3239 (patch)
tree261dad8da34bdb485097b141fecaf4feb334060e
parentf1429ec746cd413318d3a7198a9469a7f4dc51ac (diff)
added provision to set colors of hidden blocks
-rw-r--r--TurtleArt/tablock.py5
-rw-r--r--TurtleArt/tapalette.py12
-rw-r--r--plugins/turtle_blocks_extras/turtle_blocks_extras.py24
3 files changed, 39 insertions, 2 deletions
diff --git a/TurtleArt/tablock.py b/TurtleArt/tablock.py
index b709643..25e2ff8 100644
--- a/TurtleArt/tablock.py
+++ b/TurtleArt/tablock.py
@@ -24,7 +24,8 @@ import gtk
from taconstants import EXPANDABLE, EXPANDABLE_ARGS, OLD_NAMES, CONSTANTS, \
STANDARD_STROKE_WIDTH, BLOCK_SCALE, BOX_COLORS, GRADIENT_COLOR
from tapalette import palette_blocks, block_colors, expandable_blocks, \
- content_blocks, block_names, block_primitives, block_styles
+ content_blocks, block_names, block_primitives, block_styles, \
+ special_block_colors
from tasprite_factory import SVG, svg_str_to_pixbuf
import sprites
@@ -472,6 +473,8 @@ class Block:
def _set_colors(self, svg):
if self.name in BOX_COLORS:
self.colors = BOX_COLORS[self.name]
+ elif self.name in special_block_colors:
+ self.colors = special_block_colors[self.name]
else:
for p in range(len(palette_blocks)):
if self.name in palette_blocks[p]:
diff --git a/TurtleArt/tapalette.py b/TurtleArt/tapalette.py
index 6c10825..61fcb14 100644
--- a/TurtleArt/tapalette.py
+++ b/TurtleArt/tapalette.py
@@ -32,6 +32,7 @@ special_names = {} # Names for blocks without names for popup help
content_blocks = ['number', 'string', 'description', 'audio', 'video',
'journal']
value_blocks = [] # blocks whose labels are updated get added here
+special_block_colors = {}
block_styles = {'basic-style': [],
'blank-style': [],
'basic-style-head': [],
@@ -131,7 +132,7 @@ class Palette():
def add_block(self, block_name, style='basic-block', label=None,
special_name=None, default=None, prim_name=None,
help_string=None, value_block=False, content_block=False,
- logo_command=None, hidden=False):
+ logo_command=None, hidden=False, colors=None):
""" Add a new block to the palette """
block = Block(block_name)
block.set_style(style)
@@ -150,6 +151,8 @@ class Palette():
block.set_logo_command(logo_command)
if help_string is not None:
block.set_help(help_string)
+ if colors is not None:
+ block.set_colors(colors)
block.set_value_block(value_block)
block.set_content_block(content_block)
if not hidden:
@@ -195,6 +198,7 @@ class Block():
self._logo_command = None
self._value_block = False
self._content_block = False
+ self._colors = None
def add_block(self, position=None):
if self._name is None:
@@ -246,6 +250,12 @@ class Block():
if self._style in EXPANDABLE_STYLE:
expandable_blocks.append(self._name)
+ if self._colors is not None:
+ special_block_colors[self._name] = self._colors
+
+ def set_colors(self, colors=None):
+ self._colors = colors
+
def set_value_block(self, value=True):
self._value_block = value
diff --git a/plugins/turtle_blocks_extras/turtle_blocks_extras.py b/plugins/turtle_blocks_extras/turtle_blocks_extras.py
index ad31839..6aec358 100644
--- a/plugins/turtle_blocks_extras/turtle_blocks_extras.py
+++ b/plugins/turtle_blocks_extras/turtle_blocks_extras.py
@@ -161,6 +161,7 @@ Journal'))
palette.add_block('showaligned',
hidden=True,
+ colors=["#A0FF00", "#80A000"],
style='basic-style-1arg',
label=_('show aligned'),
default=_('text'),
@@ -175,6 +176,7 @@ Journal'))
primitive_dictionary['write'] = self._prim_write
palette.add_block('write',
hidden=True,
+ colors=["#A0FF00", "#80A000"],
style='basic-style-1arg',
label=_('show'),
default=[_('text'), 32],
@@ -385,6 +387,7 @@ advanced single-variable math equations, e.g., sin(x)'))
palette.add_block('myfunc2arg',
hidden=True,
+ colors=["#FF0000", "#A00000"],
style='number-style-var-arg',
label=[_('Python'), 'f(x,y)', 'x'],
prim_name='myfunction2',
@@ -397,6 +400,7 @@ advanced multi-variable math equations, e.g., sqrt(x*x+y*y)'))
palette.add_block('myfunc3arg',
hidden=True,
+ colors=["#FF0000", "#A00000"],
style='number-style-var-arg',
label=[_('Python'), 'f(x,y,z)', 'x'],
prim_name='myfunction3',
@@ -421,6 +425,7 @@ module found in the Journal'))
palette.add_block('userdefined2args',
hidden=True,
+ colors=["#FF0000", "#A00000"],
style='basic-style-var-arg',
label=' ',
prim_name='userdefined2',
@@ -433,6 +438,7 @@ module found in the Journal'))
palette.add_block('userdefined3args',
hidden=True,
+ colors=["#FF0000", "#A00000"],
style='basic-style-var-arg',
label=' ',
prim_name='userdefined3',
@@ -472,6 +478,7 @@ module found in the Journal'))
primitive_dictionary['skin'] = self._prim_reskin
palette.add_block('skin',
hidden=True,
+ colors=["#FF0000", "#A00000"],
style='basic-style-1arg',
label=_('turtle shell'),
prim_name='skin',
@@ -501,6 +508,7 @@ module found in the Journal'))
palette.add_block('sandwichcollapsed',
hidden=True,
+ colors=["#FF0000", "#A00000"],
style='invisible',
label=' ',
prim_name='nop',
@@ -510,6 +518,7 @@ click to open'))
# deprecated blocks
palette.add_block('sandwichtop',
hidden=True,
+ colors=["#FF0000", "#A00000"],
style='collapsible-top',
label=_('top of stack'),
default=_('label'),
@@ -518,6 +527,7 @@ click to open'))
palette.add_block('sandwichtop_no_arm',
hidden=True,
+ colors=["#FF0000", "#A00000"],
style='collapsible-top-no-arm',
label=_('top of a collapsible stack'),
default=_('label'),
@@ -526,6 +536,7 @@ click to open'))
palette.add_block('sandwichtop_no_arm_no_label',
hidden=True,
+ colors=["#FF0000", "#A00000"],
style='collapsible-top-no-arm-no-label',
label=[' ', _('click to open')],
prim_name='nop',
@@ -562,6 +573,7 @@ click to open'))
primitive_dictionary['bulletlist'] = self._prim_list
palette.add_block('list',
hidden=True,
+ colors=["#0606FF", "#0606A0"],
style='bullet-style',
label=_('list'),
prim_name='bulletlist',
@@ -658,6 +670,7 @@ Journal objects'))
palette.add_block('titlex',
hidden=True,
+ colors=["#0606FF", "#0606A0"],
style='box-style',
label=_('title x'),
logo_command='titlex',
@@ -666,6 +679,7 @@ Journal objects'))
palette.add_block('titley',
hidden=True,
+ colors=["#0606FF", "#0606A0"],
style='box-style',
label=_('title y'),
logo_command='titley',
@@ -674,6 +688,7 @@ Journal objects'))
palette.add_block('leftx',
hidden=True,
+ colors=["#0606FF", "#0606A0"],
style='box-style',
label=_('left x'),
prim_name='leftx',
@@ -682,6 +697,7 @@ Journal objects'))
palette.add_block('topy',
hidden=True,
+ colors=["#0606FF", "#0606A0"],
style='box-style',
label=_('top y'),
prim_name='topy',
@@ -690,6 +706,7 @@ Journal objects'))
palette.add_block('rightx',
hidden=True,
+ colors=["#0606FF", "#0606A0"],
style='box-style',
label=_('right x'),
prim_name='rightx',
@@ -698,6 +715,7 @@ Journal objects'))
palette.add_block('bottomy',
hidden=True,
+ colors=["#0606FF", "#0606A0"],
style='box-style',
label=_('bottom y'),
prim_name='bottomy',
@@ -709,6 +727,7 @@ Journal objects'))
primitive_dictionary['t1x1'] = self._prim_t1x1
palette.add_block('template1x1',
hidden=True,
+ colors=["#0606FF", "#0606A0"],
style='portfolio-style-1x1',
label=' ',
prim_name='t1x1',
@@ -722,6 +741,7 @@ Journal object (with description)'))
primitive_dictionary['t1x1a'] = self._prim_t1x1a
palette.add_block('template1x1a',
hidden=True,
+ colors=["#0606FF", "#0606A0"],
style='portfolio-style-1x1',
label=' ',
prim_name='t1x1a',
@@ -735,6 +755,7 @@ Journal object (no description)'))
primitive_dictionary['2x1'] = self._prim_t2x1
palette.add_block('template2x1',
hidden=True,
+ colors=["#0606FF", "#0606A0"],
style='portfolio-style-2x1',
label=' ',
prim_name='t2x1',
@@ -748,6 +769,7 @@ Journal objects"))
primitive_dictionary['1x2'] = self._prim_t1x2
palette.add_block('template1x2',
hidden=True,
+ colors=["#0606FF", "#0606A0"],
style='portfolio-style-1x2',
label=' ',
prim_name='t1x2',
@@ -761,6 +783,7 @@ Journal objects"))
primitive_dictionary['t2x2'] = self._prim_t2x2
palette.add_block('template2x2',
hidden=True,
+ colors=["#0606FF", "#0606A0"],
style='portfolio-style-2x2',
label=' ',
prim_name='t2x2',
@@ -774,6 +797,7 @@ Journal objects"))
palette.add_block('templatelist',
hidden=True,
+ colors=["#0606FF", "#0606A0"],
style='bullet-style',
label=' ',
prim_name='bullet',