Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarion <marion.zepf@gmail.com>2013-09-16 15:07:17 (GMT)
committer Marion <marion.zepf@gmail.com>2013-09-16 15:07:17 (GMT)
commitf693181ce295ad099a499262b1bdd9f4af9e45bf (patch)
treeb38862a65bd3b8484aef9773380d00d90561550e
parentb18ef44fecc184e3a0c7744f04ff3fc7e4640cf8 (diff)
start the plugins (tell them we're running) when the exported code is run
-rw-r--r--TurtleArt/taexportpython.py11
-rw-r--r--TurtleArt/tawindow.py4
2 files changed, 13 insertions, 2 deletions
diff --git a/TurtleArt/taexportpython.py b/TurtleArt/taexportpython.py
index 33c3979..9fa7b59 100644
--- a/TurtleArt/taexportpython.py
+++ b/TurtleArt/taexportpython.py
@@ -63,6 +63,11 @@ if __name__ == '__main__':
"""
_ACTION_STACK_START = """\
def %s():
+"""
+_START_STACK_START_ADD = """\
+ tw.start_plugins()
+"""
+_ACTION_STACK_PREAMBLE = """\
turtle = tw.turtles.get_active_turtle()
turtles = tw.turtles
canvas = tw.canvas
@@ -114,12 +119,18 @@ def _action_stack_to_python(block, lc, name="start"):
# wrap the action stack setup code around everything
name_id = _make_identifier(name)
+ if name == 'start':
+ pre_preamble = _START_STACK_START_ADD
+ else:
+ pre_preamble = ''
generated_code = _indent(generated_code, 1)
if generated_code.endswith(linesep):
newline = ""
else:
newline = linesep
snippets = [_ACTION_STACK_START % (name_id),
+ pre_preamble,
+ _ACTION_STACK_PREAMBLE,
generated_code,
newline,
_ACTION_STACK_END % (name, name_id)]
diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py
index 92c2024..a7e71d8 100644
--- a/TurtleArt/tawindow.py
+++ b/TurtleArt/tawindow.py
@@ -414,7 +414,7 @@ class TurtleArtWindow():
for plugin in self.turtleart_plugins:
plugin.setup()
- def _start_plugins(self):
+ def start_plugins(self):
''' Start is called everytime we execute blocks. '''
for plugin in self.turtleart_plugins:
plugin.start()
@@ -3134,7 +3134,7 @@ before making changes to your Turtle Blocks program'))
if self.canvas.cr_svg is None:
self.canvas.setup_svg_surface()
self.running_blocks = True
- self._start_plugins() # Let the plugins know we are running.
+ self.start_plugins() # Let the plugins know we are running.
top = find_top_block(blk)
code = self.lc.generate_code(top, self.just_blocks())
self.lc.run_blocks(code)