Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--TurtleArt/taexportpython.py8
-rw-r--r--TurtleArt/taprimitive.py2
-rw-r--r--TurtleArt/tawindow.py6
3 files changed, 11 insertions, 5 deletions
diff --git a/TurtleArt/taexportpython.py b/TurtleArt/taexportpython.py
index 99084f0..49bde06 100644
--- a/TurtleArt/taexportpython.py
+++ b/TurtleArt/taexportpython.py
@@ -66,6 +66,7 @@ def %s():
"""
_START_STACK_START_ADD = """\
tw.start_plugins()
+ global_objects = tw.get_global_objects()
"""
_ACTION_STACK_PREAMBLE = """\
turtles = tw.turtles
@@ -98,22 +99,23 @@ def save_python(tw):
for block in tops_of_stacks:
stack_name = get_stack_name(block)
if stack_name:
- pythoncode = _action_stack_to_python(block, tw.lc, name=stack_name)
+ pythoncode = _action_stack_to_python(block, tw, name=stack_name)
snippets.append(pythoncode)
snippets.append(linesep)
snippets.append(_SETUP_CODE_END)
return "".join(snippets)
-def _action_stack_to_python(block, lc, name="start"):
+def _action_stack_to_python(block, tw, name="start"):
""" Turn a stack of blocks into Python code
name -- the name of the action stack (defaults to "start") """
+
if isinstance(name, int):
name = float(name)
if not isinstance(name, basestring):
name = str(name)
# traverse the block stack and get the AST for every block
- ast_list = _walk_action_stack(block, lc)
+ ast_list = _walk_action_stack(block, tw.lc)
if not isinstance(ast_list[-1], ast.Yield):
ast_list.append(ast_yield_true())
action_stack_ast = ast.Module(body=ast_list)
diff --git a/TurtleArt/taprimitive.py b/TurtleArt/taprimitive.py
index f842f93..3f922b4 100644
--- a/TurtleArt/taprimitive.py
+++ b/TurtleArt/taprimitive.py
@@ -33,7 +33,7 @@ from talogo import (LogoCode, logoerror, NegativeRootError)
from taturtle import (Turtle, Turtles)
from tatype import *
from tautils import debug_output
-from tawindow import (global_objects, TurtleArtWindow)
+from tawindow import TurtleArtWindow, global_objects
from util import ast_extensions
diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py
index c3e6336..448dbf3 100644
--- a/TurtleArt/tawindow.py
+++ b/TurtleArt/tawindow.py
@@ -96,7 +96,8 @@ _UNFULLSCREEN_VISIBILITY_TIMEOUT = 2
_PLUGIN_SUBPATH = 'plugins'
_MACROS_SUBPATH = 'macros'
-global_objects = {} # the global instances of single-instance classes
+# the global instances of single-instance classes
+global_objects = {}
class TurtleArtWindow():
@@ -315,6 +316,9 @@ class TurtleArtWindow():
self._init_plugins()
self._setup_plugins()
+ def get_global_objects(self):
+ return global_objects
+
def _lazy_init(self):
self._init_plugins()
self._setup_plugins()