Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TurtleArt
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2012-07-21 12:57:48 (GMT)
committer Walter Bender <walter.bender@gmail.com>2012-07-21 12:57:48 (GMT)
commitcbf23a55067bbe8864cca33873b1fbf30aa6cbce (patch)
treeab3d30c3ceec8815243d443e95c9d193d84ed791 /TurtleArt
parent536a25305119214d569dfc21afffbbd2b76c29c9 (diff)
Update labels on named boxes when running in debug mode
Diffstat (limited to 'TurtleArt')
-rw-r--r--TurtleArt/tabasics.py8
-rw-r--r--TurtleArt/tablock.py2
-rw-r--r--TurtleArt/talogo.py31
3 files changed, 33 insertions, 8 deletions
diff --git a/TurtleArt/tabasics.py b/TurtleArt/tabasics.py
index 84363c4..59d482b 100644
--- a/TurtleArt/tabasics.py
+++ b/TurtleArt/tabasics.py
@@ -927,6 +927,7 @@ variable'))
prim_name='box',
default=_('my box'),
logo_command='box',
+ value_block=True,
help_string=_('named variable (numeric value)'))
self.tw.lc.def_prim('box', 1,
lambda self, x: primitive_dictionary['box'](x))
@@ -1087,10 +1088,11 @@ variable'))
if int(float(x)) == x:
x = int(x)
self.tw.lc.boxes[name + str(x)] = val
+ self.tw.lc.update_label_value('box', val, label=x)
return
-
- self.tw.lc.boxes[name] = val
- self.tw.lc.update_label_value(name, val)
+ else:
+ self.tw.lc.boxes[name] = val
+ self.tw.lc.update_label_value(name, val)
def _prim_stack(self, x):
""" Process a named stack """
diff --git a/TurtleArt/tablock.py b/TurtleArt/tablock.py
index 932085e..dd19d68 100644
--- a/TurtleArt/tablock.py
+++ b/TurtleArt/tablock.py
@@ -244,7 +244,7 @@ class Block:
return False
if self.name in block_styles['box-style']:
return False
- if self.name in ['sandwichtop', 'sandwichtop_no_label']:
+ if self.name in ['box', 'sandwichtop', 'sandwichtop_no_label']:
return False
return True
diff --git a/TurtleArt/talogo.py b/TurtleArt/talogo.py
index 25bf44c..143f584 100644
--- a/TurtleArt/talogo.py
+++ b/TurtleArt/talogo.py
@@ -608,8 +608,9 @@ class LogoCode:
self.value_blocks_to_update[name] = \
self.tw.block_list.get_similar_blocks('block', name)
- def update_label_value(self, name, value=None):
+ def update_label_value(self, name, value=None, label=None):
""" Update the label of value blocks to reflect current value """
+ # If it is a named box, we need to match the label to the box
if not self.tw.interactive_mode:
return
if self.tw.hide:
@@ -618,7 +619,16 @@ class LogoCode:
if value is None:
for block in self.value_blocks_to_update[name]:
block.spr.set_label(block_names[name][0])
- block.resize()
+ if name == 'box':
+ argblk = block.connections[-2]
+ dx = block.dx
+ block.resize()
+ if argblk is not None:
+ # Move connections over...
+ dx = (block.dx - dx) * self.tw.block_scale
+ argblk.spr.move_relative((dx, 0))
+ else:
+ block.resize()
elif self.update_values:
if type(value) == float:
valstring = str(round_int(value)).replace('.',
@@ -626,8 +636,21 @@ class LogoCode:
else:
valstring = str(value)
for block in self.value_blocks_to_update[name]:
- block.spr.set_label(block_names[name][0] + ' = ' + valstring)
- block.resize()
+ if label is None:
+ block.spr.set_label(
+ block_names[name][0] + ' = ' + valstring)
+ block.resize()
+ else:
+ argblk = block.connections[-2]
+ # Only update if label matches
+ if argblk is not None and argblk.spr.labels[0] == label:
+ block.spr.set_label(
+ block_names[name][0] + ' = ' + valstring)
+ dx = block.dx
+ block.resize()
+ # Move connections over...
+ dx = (block.dx - dx) * self.tw.block_scale
+ argblk.spr.move_relative((dx, 0))
def push_file_data_to_heap(self, dsobject):
""" push contents of a data store object (assuming json encoding) """