diff options
-rw-r--r-- | TurtleArt/tawindow.py | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py index 5c78269..61b4329 100644 --- a/TurtleArt/tawindow.py +++ b/TurtleArt/tawindow.py @@ -258,7 +258,7 @@ class TurtleArtWindow(): self._init_plugins() self.lc = LogoCode(self) - self.logo_code = [self.lc, LogoCode(self)] + self.logo_code = [self.lc] self.lock = Lock() self.event = Event() self.event.clear() @@ -274,18 +274,6 @@ class TurtleArtWindow(): self.saved_pictures = [] self.block_operation = '' - # TODO: allocate these additional LogoCode instances upon - # encountering start blocks... this is a simple kludge just to - # test two threads - # TODO: copy the object list each time a new LogoCode instance - # is created as per above. - self.logo_code.append(LogoCode(self)) - self.active_turtles.append(Turtle(self.turtles, - self.default_turtle_name)) - for lc in self.logo_code: - if lc != self.lc: - lc.oblist = self.lc.oblist - def _get_plugin_home(self): """ Look in the execution directory """ path = os.path.join(self.path, self._PLUGIN_SUBPATH) @@ -454,7 +442,19 @@ class TurtleArtWindow(): debug_output("running stack starting from %s" % ( this_start_block.name), self.running_sugar) i = start_blocks.index(this_start_block) - # TODO: ADD one logo_code instance per start block + print 'looking for instance', i + print 'length of logo_code:', len(self.logo_code) + while i > len(self.logo_code) - 1: + # Create a LogoCode instance for this start block. + self.logo_code.append(LogoCode(self)) + print 'adding logo_code instance:', \ + len(self.logo_code) - 1 + # Copy the oblist we created in _init_(). + self.logo_code[-1].oblist = self.logo_code[0].oblist + # Add one new turtle per start block. + self.active_turtles.append( + Turtle(self.turtles, self.default_turtle_name)) + # gobject.idle_add(self._run_stack, blk, self.logo_code[i]) self._run_stack_thread(blk, self.logo_code[i]) # return @@ -1909,7 +1909,12 @@ class TurtleArtWindow(): lc.find_value_blocks() # Are there blocks to update? self._start_plugins() # Let the plugins know we are running. top = find_top_block(blk) - self.active_turtle = self.active_turtles[self.logo_code.index(lc)] + i = self.logo_code.index(lc) + print 'running instance:', i + if i < len(self.active_turtles): + self.active_turtle = self.active_turtles[i] + else: + print 'active turtle list is short', len(self.active_turtles) lc.run_blocks(top, self.just_blocks(), True) if self.interactive_mode: gobject.idle_add(lc.doevalstep) |