Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TurtleArt/talogo.py
diff options
context:
space:
mode:
Diffstat (limited to 'TurtleArt/talogo.py')
-rw-r--r--TurtleArt/talogo.py53
1 files changed, 38 insertions, 15 deletions
diff --git a/TurtleArt/talogo.py b/TurtleArt/talogo.py
index a2901eb..590797c 100644
--- a/TurtleArt/talogo.py
+++ b/TurtleArt/talogo.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#Copyright (c) 2007-8, Playful Invention Company.
-#Copyright (c) 2008-11, Walter Bender
+#Copyright (c) 2008-12, Walter Bender
#Copyright (c) 2008-10, Raúl Gutiérrez Segalés
#Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -62,10 +62,13 @@ class symbol:
class logoerror(Exception):
def __init__(self, value):
+ print value
self.value = value
def __str__(self):
- return repr(self.value)
+ # return repr(self.value)
+ return str(self.value)
+
class HiddenBlock:
@@ -82,6 +85,7 @@ class HiddenBlock:
# Utility functions
+
def _just_stop():
""" yield False to stop stack """
yield False
@@ -174,7 +178,6 @@ class LogoCode:
self.stacks[k] = None
self.stacks['stack1'] = None
self.stacks['stack2'] = None
- self.tw.saving_svg = False
# Save state in case there is a hidden macro expansion
self.save_blocks = None
@@ -212,6 +215,7 @@ class LogoCode:
x = b.connections[1].values[0]
except IndexError:
self.tw.showlabel('#nostack')
+ self.tw.showblocks()
return None
if type(convert(x, float, False)) == float:
if int(float(x)) == x:
@@ -249,8 +253,6 @@ class LogoCode:
dock = blk.docks[0]
if len(dock) > 4: # There could be a '(', ')', '[' or ']'.
code.append(dock[4])
- if blk.name == 'savesvg':
- self.tw.saving_svg = True
if blk.primitive is not None: # make a tuple (prim, blk)
# special case: expand 'while' and 'until' primitives
try:
@@ -265,8 +267,9 @@ class LogoCode:
except ValueError:
code.append(float(ord(blk.values[0][0])))
elif blk.name == 'string' or \
- blk.name == 'title': # deprecated block
- if type(blk.values[0]) == float or type(blk.values[0]) == int:
+ blk.name == 'title': # deprecated block
+ if type(blk.values[0]) == float or \
+ type(blk.values[0]) == int:
if int(blk.values[0]) == blk.values[0]:
blk.values[0] = int(blk.values[0])
code.append('#s' + str(blk.values[0]))
@@ -342,13 +345,23 @@ class LogoCode:
""" Step through the list. """
if self.tw.running_sugar:
self.tw.activity.stop_turtle_button.set_icon("stopiton")
+ self.tw.activity.stop_turtle_button.set_tooltip(
+ _('Stop turtle'))
elif self.tw.interactive_mode:
self.tw.toolbar_shapes['stopiton'].set_layer(TAB_LAYER)
self.running = True
self.icall(self.evline, blklist)
yield True
if self.tw.running_sugar:
- self.tw.activity.stop_turtle_button.set_icon("stopitoff")
+ # self.tw.activity.stop_turtle_button.set_icon("stopitoff")
+ if self.tw.step_time == 0 and self.tw.selected_blk is None:
+ self.tw.activity.stop_turtle_button.set_icon("hideshowoff")
+ self.tw.activity.stop_turtle_button.set_tooltip(
+ _('Show blocks'))
+ else:
+ self.tw.activity.stop_turtle_button.set_icon("stopitoff")
+ self.tw.activity.stop_turtle_button.set_tooltip(
+ _('Stop turtle'))
elif self.tw.interactive_mode:
self.tw.toolbar_shapes['stopiton'].hide()
yield False
@@ -403,6 +416,7 @@ class LogoCode:
if self.bindex is not None:
self.tw.block_list.list[self.bindex].highlight()
+ self.tw.showblocks()
raise logoerror(str(self.iresult))
self.iline = oldiline
self.ireturn()
@@ -441,6 +455,7 @@ class LogoCode:
self.cfun, self.arglist = token, []
if token.nargs == None:
+ self.tw.showblocks()
raise logoerror("#noinput")
for i in range(token.nargs):
self._no_args_check()
@@ -461,6 +476,7 @@ class LogoCode:
result = self.cfun.fcn(self, *self.arglist)
self.cfun, self.arglist = oldcfun, oldarglist
if self.arglist is not None and result == None:
+ self.tw.showblocks()
raise logoerror("%s %s %s" % \
(oldcfun.name, _("did not output to"), self.cfun.name))
self.ireturn(result)
@@ -495,7 +511,8 @@ class LogoCode:
self.tw.active_turtle.show()
return False
except logoerror, e:
- self.tw.showlabel('syntaxerror', str(e)[1:-1])
+ self.tw.showblocks()
+ self.tw.showlabel('syntaxerror', str(e))
self.tw.turtles.show_all()
return False
return True
@@ -517,12 +534,14 @@ class LogoCode:
errormsg = ''
else:
errormsg = "%s %s" % (_("I don't know how to"), _(token.name))
+ self.tw.showblocks()
raise logoerror(errormsg)
def _no_args_check(self):
""" Missing argument ? """
if self.iline and self.iline[0] is not self.symnothing:
return
+ self.tw.showblocks()
raise logoerror("#noinput")
#
@@ -542,7 +561,7 @@ class LogoCode:
def prim_clear(self):
""" Clear screen """
- self.tw.clear_plugins()
+ self.tw.clear_plugins()
if self.tw.gst_available:
from tagplay import stop_media
# stop_media(self) # TODO: gplay variable
@@ -562,6 +581,7 @@ class LogoCode:
elif type(n) == str:
return int(ord(n[0]))
else:
+ self.tw.showblocks()
raise logoerror("%s %s %s %s" \
% (self.cfun.name, _("doesn't like"), str(n), _("as input")))
@@ -660,8 +680,10 @@ class LogoCode:
self.y2ty() - int(h / 2), w, h,
self.filepath)
elif offset:
- self.tw.canvas.draw_pixbuf(self.pixbuf, 0, 0, self.x2tx(),
- self.y2ty() - h, w, h, self.filepath)
+ self.tw.canvas.draw_pixbuf(self.pixbuf, 0, 0,
+ self.x2tx(),
+ self.y2ty() - h,
+ w, h, self.filepath)
else:
self.tw.canvas.draw_pixbuf(self.pixbuf, 0, 0,
self.x2tx(),
@@ -733,11 +755,11 @@ class LogoCode:
# into trouble if any of these block types (forever, while,
# until. ifelse, stopstack, or stack) is changed in tablock.py
if b.name == 'while':
- while_blk = True
+ while_blk = True
else:
while_blk = False
if b.name == 'until':
- until_blk = True
+ until_blk = True
else:
until_blk = False
@@ -849,7 +871,8 @@ class LogoCode:
c = whileflow.connections[0]
whileflow.connections[0] = None
code = self._blocks_to_code(whileflow)
- self.stacks['stack3' + str(action_flow_name)] = self._readline(code)
+ self.stacks['stack3' + str(action_flow_name)] = \
+ self._readline(code)
whileflow.connections[0] = c
# Save the connections so we can restore them later