Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPootle daemon <pootle@pootle.sugarlabs.org>2013-11-06 05:31:20 (GMT)
committer Pootle daemon <pootle@pootle.sugarlabs.org>2013-11-06 05:31:20 (GMT)
commit170715b800f972c2d12cd63a23245c7b09194764 (patch)
treee9515d66d03c1b19a9e145006eb91e5a69a1d534
parent33697496490251b3fea04614c98a088ba0e04c6a (diff)
parentab11c18934d9f8f33e597cf7db0353859b63bef9 (diff)
Merge branch 'master' of git.sugarlabs.org:turtleart/mainline
-rw-r--r--NEWS8
-rw-r--r--TurtleArt/taturtle.py61
-rw-r--r--TurtleArt/tawindow.py1
-rw-r--r--plugins/turtle_blocks_extras/turtle_blocks_extras.py4
-rw-r--r--samples/game-snake.tb66
5 files changed, 57 insertions, 83 deletions
diff --git a/NEWS b/NEWS
index 90a68da..7dc9ee9 100644
--- a/NEWS
+++ b/NEWS
@@ -1,10 +1,14 @@
193
ENHANCEMENTS:
-* Add Marian Zepf's export Python
-* Add busy cursor while project is loading from store
+* Merged Marian Zepf's export Python branch (This is really fun. Give it a try.)
+* Added busy cursor while project is loading from store
+* New sample program from Cynthia Solomon
* New translations
+BUG FIX:
+* Prevent text blocks from docking to blocks requiring numeric arguments
+
192
ENHANCEMENTS:
diff --git a/TurtleArt/taturtle.py b/TurtleArt/taturtle.py
index 02d4d31..beed99d 100644
--- a/TurtleArt/taturtle.py
+++ b/TurtleArt/taturtle.py
@@ -546,12 +546,7 @@ class Turtle:
def right(self, degrees, share=True):
''' Rotate turtle clockwise '''
- try:
- self._heading += degrees
- except (TypeError, ValueError):
- debug_output('bad value sent to %s' % (__name__),
- self._turtles.turtle_window.running_sugar)
- return
+ self._heading += degrees
self._heading %= 360
self._update_sprite_heading()
@@ -562,12 +557,7 @@ class Turtle:
self._turtles.turtle_window.send_event(event)
def left(self, degrees, share=True):
- try:
- degrees = 0 - degrees
- except:
- debug_output('bad value sent to %s' % (__name__),
- self._turtles.turtle_window.running_sugar)
- return
+ degrees = 0 - degrees
self.right(degrees, share)
def _draw_line(self, old, new, pendown):
@@ -583,17 +573,11 @@ class Turtle:
self._poly_points.append(('line', pos2[0], pos2[1]))
def forward(self, distance, share=True):
- print distance
scaled_distance = distance * self._turtles.turtle_window.coord_scale
old = self.get_xy()
- try:
- xcor = old[0] + scaled_distance * sin(self._heading * DEGTOR)
- ycor = old[1] + scaled_distance * cos(self._heading * DEGTOR)
- except (TypeError, ValueError):
- debug_output('bad value sent to %s' % (__name__),
- self._turtles.turtle_window.running_sugar)
- return
+ xcor = old[0] + scaled_distance * sin(self._heading * DEGTOR)
+ ycor = old[1] + scaled_distance * cos(self._heading * DEGTOR)
self._draw_line(old, (xcor, ycor), True)
self.move_turtle((xcor, ycor))
@@ -604,27 +588,17 @@ class Turtle:
self._turtles.turtle_window.send_event(event)
def backward(self, distance, share=True):
- try:
- distance = 0 - distance
- except:
- debug_output('bad value sent to %s' % (__name__),
- self._turtles.turtle_window.running_sugar)
- return
+ distance = 0 - distance
self.forward(distance, share)
def set_xy(self, x, y, share=True, pendown=True, dragging=False):
old = self.get_xy()
- try:
- if dragging:
- xcor = x
- ycor = y
- else:
- xcor = x * self._turtles.turtle_window.coord_scale
- ycor = y * self._turtles.turtle_window.coord_scale
- except (TypeError, ValueError):
- debug_output('bad value sent to %s' % (__name__),
- self._turtles.turtle_window.running_sugar)
- return
+ if dragging:
+ xcor = x
+ ycor = y
+ else:
+ xcor = x * self._turtles.turtle_window.coord_scale
+ ycor = y * self._turtles.turtle_window.coord_scale
self._draw_line(old, (xcor, ycor), pendown)
self.move_turtle((xcor, ycor))
@@ -639,15 +613,10 @@ class Turtle:
''' Draw an arc '''
if self._pen_state:
self._turtles.turtle_window.canvas.set_source_rgb()
- try:
- if a < 0:
- pos = self.larc(-a, r)
- else:
- pos = self.rarc(a, r)
- except (TypeError, ValueError):
- debug_output('bad value sent to %s' % (__name__),
- self._turtles.turtle_window.running_sugar)
- return
+ if a < 0:
+ pos = self.larc(-a, r)
+ else:
+ pos = self.rarc(a, r)
self.move_turtle(pos)
diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py
index 6d9ca0a..d665b9f 100644
--- a/TurtleArt/tawindow.py
+++ b/TurtleArt/tawindow.py
@@ -3634,6 +3634,7 @@ before making changes to your program'))
def get_keyboard_input(self):
""" Query keyboard and update cached keyboard input """
+ self.window.grab_focus()
if len(self.keypress) == 1:
self.keyboard = ord(self.keypress[0])
elif self.keypress in KEY_DICT:
diff --git a/plugins/turtle_blocks_extras/turtle_blocks_extras.py b/plugins/turtle_blocks_extras/turtle_blocks_extras.py
index d99a4c5..131d14b 100644
--- a/plugins/turtle_blocks_extras/turtle_blocks_extras.py
+++ b/plugins/turtle_blocks_extras/turtle_blocks_extras.py
@@ -787,8 +787,8 @@ module found in the Journal'))
string_or_number=True,
help_string=_('chooses which turtle to command'))
self.tw.lc.def_prim('addturtle', 1,
- lambda self, x:
- self.tw.turtles.set_turtle(x))
+ Primitive(self.tw.turtles.set_turtle,
+ arg_descs=[ArgSlot(TYPE_STRING)]))
palette.add_block('turtlex',
style='number-style-1arg',
diff --git a/samples/game-snake.tb b/samples/game-snake.tb
index 4e8215c..aa157c3 100644
--- a/samples/game-snake.tb
+++ b/samples/game-snake.tb
@@ -1,15 +1,15 @@
-[[0, ["start", 2.0], 200, 180, [null, 56]],
+[[0, ["start", 2.0], 183, 131, [null, 56]],
[1, "hat", 740, 420, [null, 2, 13]],
[2, ["string", "left"], 798, 432, [1, null]],
[3, "hat", 740, 180, [null, 4, 12]],
[4, ["string", "right"], 798, 192, [3, null]],
-[5, "stack", 520, 276, [11, 6, 7]],
-[6, ["string", "left"], 578, 276, [5, null]],
-[7, "stack", 520, 318, [5, 8, 9]],
-[8, ["string", "right"], 578, 318, [7, null]],
-[9, "forward", 520, 360, [7, 10, 51]],
-[10, ["number", 10], 591, 360, [9, null]],
-[11, "kbinput", 520, 234, [33, 5]],
+[5, "stack", 498, 281, [11, 6, 7]],
+[6, ["string", "left"], 556, 281, [5, null]],
+[7, "stack", 498, 323, [5, 8, 9]],
+[8, ["string", "right"], 556, 323, [7, null]],
+[9, "forward", 498, 365, [7, 10, 51]],
+[10, ["number", 10], 569, 365, [9, null]],
+[11, "kbinput", 498, 239, [33, 5]],
[12, ["vspace", 0], 740, 234, [3, 14]],
[13, ["vspace", 0], 740, 474, [1, 15]],
[14, ["if", 0], 740, 276, [12, 16, 20, null]],
@@ -22,39 +22,39 @@
[21, ["number", 10], 816, 342, [20, null]],
[22, "left", 758, 582, [15, 23, null]],
[23, ["number", 10], 816, 582, [22, null]],
-[24, "wait", 218, 586, [35, 25, null]],
-[25, ["number", 0.1], 276, 586, [24, null]],
+[24, "wait", 201, 537, [35, 25, null]],
+[25, ["number", 0.1], 259, 537, [24, null]],
[26, "forward", 1020, 276, [30, 27, 39]],
-[27, ["number", 5.0], 1091, 276, [26, null]],
+[27, ["number", 5], 1091, 276, [26, null]],
[28, "back", 1020, 402, [39, 29, 31]],
-[29, ["number", 5.0], 1078, 402, [28, null]],
+[29, ["number", 5], 1078, 402, [28, null]],
[30, "penup", 1020, 234, [49, 26]],
[31, "pendown", 1020, 444, [28, null]],
-[32, "showblocks", 200, 646, [47, null]],
-[33, "hat", 520, 180, [null, 34, 11]],
-[34, ["string", "action"], 578, 192, [33, null]],
-[35, "stack", 218, 544, [47, 36, 24]],
-[36, ["string", "action"], 276, 544, [35, null]],
-[37, "setpensize", 200, 352, [57, 38, 54]],
-[38, ["number", 8.0], 302, 352, [37, null]],
+[32, "showblocks", 183, 597, [47, null]],
+[33, "hat", 498, 185, [null, 34, 11]],
+[34, ["string", "action"], 556, 197, [33, null]],
+[35, "stack", 201, 495, [47, 36, 24]],
+[36, ["string", "action"], 259, 495, [35, null]],
+[37, "setpensize", 183, 303, [57, 38, 54]],
+[38, ["number", 8], 285, 303, [37, null]],
[39, ["storein", 0], 1020, 318, [26, 40, 41, 28]],
[40, ["string", "color"], 1088, 318, [39, null]],
[41, "see", 1088, 360, [39, null]],
-[42, ["equal2", 0], 256, 444, [47, 43, 53, null]],
-[43, "box", 312, 444, [42, 44, null]],
-[44, ["string", "color"], 367, 444, [43, null]],
+[42, ["equal2", 0], 239, 395, [47, 43, 53, null]],
+[43, "box", 295, 395, [42, 44, null]],
+[44, ["string", "color"], 350, 395, [43, null]],
[45, ["number", 3], 852, 242, [16, null]],
[46, ["number", 1], 852, 482, [17, null]],
-[47, ["until", 21], 200, 478, [48, 42, 35, 32]],
-[48, ["vspace", 0], 200, 436, [54, 47]],
+[47, ["until", 21], 183, 429, [48, 42, 35, 32]],
+[48, ["vspace", 0], 183, 387, [54, 47]],
[49, "hat", 1020, 180, [null, 50, 30]],
[50, ["string", "look ahead"], 1078, 192, [49, null]],
-[51, "stack", 520, 402, [9, 52, null]],
-[52, ["string", "look ahead"], 578, 402, [51, null]],
-[53, "red", 312, 486, [42, null]],
-[54, "setcolor", 200, 394, [37, 55, 48]],
-[55, "red", 277, 394, [54, null]],
-[56, "clean", 200, 226, [0, 57]],
-[57, ["storein", 0], 200, 268, [56, 58, 59, 37]],
-[58, ["string", "color"], 268, 268, [57, null]],
-[59, "blue", 268, 310, [57, null]]]
+[51, "stack", 498, 407, [9, 52, null]],
+[52, ["string", "look ahead"], 556, 407, [51, null]],
+[53, "red", 295, 437, [42, null]],
+[54, "setcolor", 183, 345, [37, 55, 48]],
+[55, "red", 260, 345, [54, null]],
+[56, "clean", 183, 177, [0, 57]],
+[57, ["storein", 0], 183, 219, [56, 58, 59, 37]],
+[58, ["string", "color"], 251, 219, [57, null]],
+[59, "blue", 251, 261, [57, null]]]