Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TurtleArt/talogo.py
diff options
context:
space:
mode:
authorWalter Bender <walter@sugarlabs.org>2010-10-20 00:53:23 (GMT)
committer Walter Bender <walter@sugarlabs.org>2010-10-20 00:53:23 (GMT)
commit1263d238bba635f0a5900f2f69933d3bf8b27c51 (patch)
tree2ae9d46f2115835d537b763e61d448e383ffd68d /TurtleArt/talogo.py
parent25320dff083ef6dfeadf416956353bc42cd7d54c (diff)
show box values on box label
Diffstat (limited to 'TurtleArt/talogo.py')
-rw-r--r--TurtleArt/talogo.py30
1 files changed, 26 insertions, 4 deletions
diff --git a/TurtleArt/talogo.py b/TurtleArt/talogo.py
index 0d467ac..cbd839b 100644
--- a/TurtleArt/talogo.py
+++ b/TurtleArt/talogo.py
@@ -34,7 +34,7 @@ except:
pass
from taconstants import PALETTES, PALETTE_NAMES, TAB_LAYER, BLACK, WHITE, \
- DEFAULT_SCALE, ICON_SIZE
+ DEFAULT_SCALE, ICON_SIZE, BLOCK_NAMES
from tagplay import play_audio, play_movie_from_file, stop_media
from tajail import myfunc, myfunc_import
from tautils import get_pixbuf_from_journal, movie_media_type, convert, \
@@ -270,6 +270,24 @@ def millis():
return int(clock() * 1000)
+def update_label_value(tw, name, value=None):
+ """ Update the label of value blocks to reflect current value """
+ if tw.hide or not tw.interactive_mode:
+ return
+ list = tw.block_list.get_all_blocks_of_same_type_and_name(
+ 'block', name)
+ if value is None:
+ for block in list:
+ block.spr.set_label(BLOCK_NAMES[name][0])
+ else:
+ if type(value) == float:
+ valstring = str(round_int(value)).replace('.', tw.decimal_point)
+ else:
+ valstring = str(value)
+ for block in list:
+ block.spr.set_label(BLOCK_NAMES[name][0] + ' = ' + valstring)
+
+
class LogoCode:
""" A class for parsing Logo code """
@@ -822,6 +840,8 @@ class LogoCode:
self.tw.set_polar(False)
self.tw.set_cartesian(False)
self.hidden_turtle = None
+ for name in ['box1', 'box2']:
+ update_label_value(self.tw, name)
def prim_start(self):
""" Start block: recenter """
@@ -1057,13 +1077,15 @@ class LogoCode:
def prim_setbox(self, name, x, val):
""" Define value of named box """
- if x is None:
- self.boxes[name] = val
- else:
+ if x is not None:
if type(convert(x, float, False)) == float:
if int(float(x)) == x:
x = int(x)
self.boxes[name + str(x)] = val
+ return
+
+ self.boxes[name] = val
+ update_label_value(self.tw, name, val)
def prim_push(self, val):
""" Push value onto FILO """