From 08003c08d80e8ba4418b35e6e7fb28059c75da74 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Mon, 25 Nov 2013 02:50:03 +0000 Subject: add turtle = after clean block in python export --- (limited to 'TurtleArt') diff --git a/TurtleArt/tabasics.py b/TurtleArt/tabasics.py index 9954db9..da3355b 100644 --- a/TurtleArt/tabasics.py +++ b/TurtleArt/tabasics.py @@ -198,7 +198,8 @@ turtle')) Primitive(self.tw.lc.clear_value_blocks), Primitive(self.tw.lc.reset_internals), Primitive(self.tw.canvas.clearscreen), - Primitive(self.tw.turtles.reset_turtles) + Primitive(self.tw.turtles.reset_turtles), + Primitive(self.tw.lc.active_turtle) ])])) palette.add_block('left', diff --git a/TurtleArt/talogo.py b/TurtleArt/talogo.py index 775af0f..5423fea 100644 --- a/TurtleArt/talogo.py +++ b/TurtleArt/talogo.py @@ -735,6 +735,9 @@ class LogoCode: """ Stop execution of a stack """ self.procstop = True + def active_turtle(self): + self.tw.turtles.get_turtle() + def prim_turtle(self, name): self.tw.turtles.set_turtle(name) diff --git a/TurtleArt/taprimitive.py b/TurtleArt/taprimitive.py index b689de5..99b1236 100644 --- a/TurtleArt/taprimitive.py +++ b/TurtleArt/taprimitive.py @@ -486,6 +486,12 @@ class Primitive(object): new_ast = value_to_ast(prim) if isinstance(new_ast, ast.AST): ast_list.append(new_ast) + ''' + # Fix Me: only needed for clean group + if self == Primitive.group: + text = 'turtle = turtles.get_active_turtle()' + ast_list.append(ast_extensions.ExtraCode(text)) + ''' return ast_list # set turtle @@ -494,6 +500,10 @@ class Primitive(object): return [get_call_ast('logo.prim_turtle', new_arg_asts), ast_extensions.ExtraCode(text)] + elif self == LogoCode.active_turtle: + text = 'turtle = turtles.get_active_turtle()' + return ast_extensions.ExtraCode(text) + # comment elif self == Primitive.comment: if isinstance(new_arg_asts[0], ast.Str): -- cgit v0.9.1