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-08-21 15:44:34 (GMT)
committer Marion <marion.zepf@gmail.com>2013-08-21 15:44:34 (GMT)
commitfbaaf7bd31a8fb5194afb5f42f76470fe3b684f4 (patch)
tree9be2bd7bc2e22851c0f553a8a96c7dedf868b4e0
parent029b30bf51a1f614cba8b1ff94dcbc4bd32b41f7 (diff)
use the global_objects dict to set the first argument of Primitives
-rw-r--r--TurtleArt/taprimitive.py31
1 files changed, 17 insertions, 14 deletions
diff --git a/TurtleArt/taprimitive.py b/TurtleArt/taprimitive.py
index 5c44d63..48972ae 100644
--- a/TurtleArt/taprimitive.py
+++ b/TurtleArt/taprimitive.py
@@ -28,7 +28,7 @@ from taconstants import (Color, CONSTANTS)
from talogo import LogoCode
from taturtle import (Turtle, Turtles)
from tautils import debug_output
-from tawindow import TurtleArtWindow
+from tawindow import (global_objects, TurtleArtWindow)
class PyExportError(BaseException):
@@ -264,20 +264,23 @@ class Primitive(object):
on what this primitive wants as its first arg). This argument is
also exempt from the slot wrappers. """
- # replace or remove the first argument if it is a LogoCode instance
- first_arg = None
+ # remove the first argument if it is a LogoCode instance
if runtime_args and isinstance(runtime_args[0], LogoCode):
- (lc, runtime_args) = (runtime_args[0], runtime_args[1:])
- if self.wants_turtle():
- first_arg = lc.tw.turtles.get_active_turtle()
- elif self.wants_turtles():
- first_arg = lc.tw.turtles
- elif self.wants_canvas():
- first_arg = lc.tw.canvas
- elif self.wants_logocode():
- first_arg = lc
- elif self.wants_tawindow():
- first_arg = lc.tw
+ runtime_args = runtime_args[1:]
+
+ # what does this primitive want as its first argument?
+ if self.wants_turtle():
+ first_arg = global_objects["turtles"].get_active_turtle()
+ elif self.wants_turtles():
+ first_arg = global_objects["turtles"]
+ elif self.wants_canvas():
+ first_arg = global_objects["canvas"]
+ elif self.wants_logocode():
+ first_arg = global_objects["logo"]
+ elif self.wants_tawindow():
+ first_arg = global_objects["window"]
+ else:
+ first_arg = None
# constant arguments
(all_args, all_kwargs) = self._add_constant_args(runtime_args,