From f693181ce295ad099a499262b1bdd9f4af9e45bf Mon Sep 17 00:00:00 2001 From: Marion Date: Mon, 16 Sep 2013 15:07:17 +0000 Subject: start the plugins (tell them we're running) when the exported code is run --- 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) -- cgit v0.9.1