Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TurtleArt
diff options
context:
space:
mode:
authorMarion <marion.zepf@gmail.com>2013-10-07 19:20:12 (GMT)
committer Marion <marion.zepf@gmail.com>2013-10-07 19:20:12 (GMT)
commitc5160558417e8e2f522afa23ed718fcd059c1ece (patch)
tree3e77e27320283fa24ee76f58c84c72748a25b45b /TurtleArt
parenta78ae458c2ddc79d3dc3260536de8c93aba33e72 (diff)
parent9a72bd2af36099323c245a066d13b6464d795a32 (diff)
Merge remote-tracking branch 'mainline/master' into type-system
Conflicts: plugins/turtle_blocks_extras/turtle_blocks_extras.py -- accept all incoming changes from mainline/master
Diffstat (limited to 'TurtleArt')
-rw-r--r--TurtleArt/tablock.py4
-rw-r--r--TurtleArt/tacollaboration.py6
-rw-r--r--TurtleArt/taturtle.py26
-rw-r--r--TurtleArt/tautils.py6
-rw-r--r--TurtleArt/tawindow.py37
5 files changed, 51 insertions, 28 deletions
diff --git a/TurtleArt/tablock.py b/TurtleArt/tablock.py
index f258029..b39ceaa 100644
--- a/TurtleArt/tablock.py
+++ b/TurtleArt/tablock.py
@@ -629,7 +629,7 @@ class Block:
if self.spr is None:
return
if isinstance(self.name, unicode):
- self.name = self.name.encode('ascii', 'replace')
+ self.name = self.name.encode('utf-8')
if self.name in content_blocks:
n = len(self.values)
if n == 0:
@@ -710,7 +710,7 @@ class Block:
self.svg.set_stroke_width(STANDARD_STROKE_WIDTH)
self.svg.clear_docks()
if isinstance(self.name, unicode):
- self.name = self.name.encode('ascii', 'replace')
+ self.name = self.name.encode('utf-8')
for k in block_styles.keys():
if self.name in block_styles[k]:
if isinstance(self.block_methods[k], list):
diff --git a/TurtleArt/tacollaboration.py b/TurtleArt/tacollaboration.py
index 26a21d7..4f4406b 100644
--- a/TurtleArt/tacollaboration.py
+++ b/TurtleArt/tacollaboration.py
@@ -75,7 +75,7 @@ class Collaboration():
'f': self._move_forward,
'a': self._move_in_arc,
'r': self._rotate_turtle,
- 'x': self._setxy,
+ 'x': self._set_xy,
'W': self._draw_text,
'c': self._set_pen_color,
'g': self._set_pen_gray_level,
@@ -347,12 +347,12 @@ class Collaboration():
self._tw.turtles.set_turtle(nick)
self._tw.turtles.get_active_turtle().set_heading(h, False)
- def _setxy(self, payload):
+ def _set_xy(self, payload):
if len(payload) > 0:
[nick, [x, y]] = data_from_string(payload)
if nick != self._tw.nick:
self._tw.turtles.set_turtle(nick)
- self._tw.turtles.get_active_turtle().set_xy(x, y, False)
+ self._tw.turtles.get_active_turtle().set_xy(x, y, share=False)
def _draw_text(self, payload):
if len(payload) > 0:
diff --git a/TurtleArt/taturtle.py b/TurtleArt/taturtle.py
index 1f616c0..68b97cc 100644
--- a/TurtleArt/taturtle.py
+++ b/TurtleArt/taturtle.py
@@ -34,6 +34,7 @@ from tacanvas import wrap100, COLOR_TABLE
from sprites import Sprite
from tautils import (debug_output, data_to_string, round_int, get_path,
image_to_base64)
+from TurtleArt.talogo import logoerror
SHAPES = 36
DEGTOR = pi / 180.
@@ -151,13 +152,34 @@ class Turtles:
self._active_turtle.hide()
self.set_turtle(self._default_turtle_name)
+ def get_turtle_x(self, turtle_name):
+ if turtle_name not in self.dict:
+ debug_output('%s not found in turtle dictionary' % (turtle_name),
+ self.turtle_window.running_sugar)
+ raise logoerror("#syntaxerror")
+ return self.dict[turtle_name].get_x()
+
+ def get_turtle_y(self, turtle_name):
+ if turtle_name not in self.dict:
+ debug_output('%s not found in turtle dictionary' % (turtle_name),
+ self.turtle_window.running_sugar)
+ raise logoerror("#syntaxerror")
+ return self.dict[turtle_name].get_y()
+
+ def get_turtle_heading(self, turtle_name):
+ if turtle_name not in self.dict:
+ debug_output('%s not found in turtle dictionary' % (turtle_name),
+ self.turtle_window.running_sugar)
+ raise logoerror("#syntaxerror")
+ return self.dict[turtle_name].get_heading()
+
def set_turtle(self, turtle_name, colors=None):
''' Select the current turtle and associated pen status '''
if turtle_name not in self.dict:
# if it is a new turtle, start it in the center of the screen
self._active_turtle = self.get_turtle(turtle_name, True, colors)
self._active_turtle.set_heading(0.0, False)
- self._active_turtle.set_xy(0.0, 0.0, False, pendown=False)
+ self._active_turtle.set_xy(0.0, 0.0, share=False, pendown=False)
self._active_turtle.set_pen_state(True)
elif colors is not None:
self._active_turtle = self.get_turtle(turtle_name, False)
@@ -467,7 +489,7 @@ class Turtle:
self.spr.set_layer(TURTLE_LAYER)
self._hidden = False
self.move_turtle_spr((self._x, self._y))
- self.set_heading(self._heading)
+ self.set_heading(self._heading, share=False)
if self.label_block is not None:
self.label_block.spr.set_layer(TURTLE_LAYER + 1)
diff --git a/TurtleArt/tautils.py b/TurtleArt/tautils.py
index 650f2ec..634ee01 100644
--- a/TurtleArt/tautils.py
+++ b/TurtleArt/tautils.py
@@ -184,7 +184,7 @@ def find_hat(data):
def _to_str(text):
''' Convert whatever to a str type '''
if isinstance(text, unicode):
- return text.encode('ascii', 'replace')
+ return text.encode('utf-8')
elif isinstance(text, str):
return text
else:
@@ -369,7 +369,7 @@ def data_from_string(text):
if isinstance(text, str):
return json_load(text.replace(']],\n', ']], '))
elif isinstance(text, unicode):
- text = text.encode('ascii', 'replace')
+ text = text.encode('utf-8')
return json_load(text.replace(']],\n', ']], '))
else:
print 'type error (%s) in data_from_string' % (type(text))
@@ -413,7 +413,7 @@ def save_picture(canvas, file_name):
cr.set_source_surface(x_surface)
cr.paint()
if isinstance(file_name, unicode):
- img_surface.write_to_png(str(file_name.encode('ascii', 'replace')))
+ img_surface.write_to_png(str(file_name.encode('utf-8')))
else:
img_surface.write_to_png(str(file_name))
diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py
index 865e8de..b01832c 100644
--- a/TurtleArt/tawindow.py
+++ b/TurtleArt/tawindow.py
@@ -1469,7 +1469,7 @@ class TurtleArtWindow():
self.toolbar_shapes['stopiton'].set_layer(TAB_LAYER)
self.showlabel('status',
label=_('Please hit the Stop Button \
-before making changes to your Turtle Blocks program'))
+before making changes to your program'))
self._autohide_shape = True
return True
@@ -1602,13 +1602,13 @@ before making changes to your Turtle Blocks program'))
found_the_action_block = False
bname = _('action')
if isinstance(bname, unicode):
- bname = bname.encode('ascii', 'replace')
+ bname = bname.encode('utf-8')
for sblk in similars:
cblk = sblk.connections[1]
if cblk is not None:
blabel = cblk.spr.labels[0]
if isinstance(blabel, unicode):
- blabel = blabel.encode('ascii', 'replace')
+ blabel = blabel.encode('utf-8')
if bname == blabel:
found_the_action_block = True
# If there is an action block in use, change the name
@@ -1836,7 +1836,7 @@ before making changes to your Turtle Blocks program'))
if isinstance(name, (float, int)):
return
if isinstance(name, unicode):
- name = name.encode('ascii', 'replace')
+ name = name.encode('utf-8')
for blk in self.just_blocks():
if self._action_name(blk, hat=False):
if blk.spr.labels[0] == self._saved_action_name:
@@ -1854,7 +1854,7 @@ before making changes to your Turtle Blocks program'))
if isinstance(name, (float, int)):
return
if isinstance(name, unicode):
- name = name.encode('ascii', 'replace')
+ name = name.encode('utf-8')
for blk in self.just_blocks():
if self._box_name(blk, storein=False):
if blk.spr.labels[0] == self._saved_box_name:
@@ -1872,7 +1872,7 @@ before making changes to your Turtle Blocks program'))
if isinstance(name, (float, int)):
return
if isinstance(name, unicode):
- name = name.encode('ascii', 'replace')
+ name = name.encode('utf-8')
for blk in self.just_blocks():
if self._box_name(blk, storein=True):
if blk.spr.labels[0] == self._saved_box_name:
@@ -1895,11 +1895,11 @@ before making changes to your Turtle Blocks program'))
# (3) The list of proto blocks on the palette
# (4) The list of block names
if isinstance(name, unicode):
- name = name.encode('ascii', 'replace')
+ name = name.encode('utf-8')
if isinstance(old, unicode):
- old = old.encode('ascii', 'replace')
+ old = old.encode('utf-8')
if isinstance(new, unicode):
- new = new.encode('ascii', 'replace')
+ new = new.encode('utf-8')
if old == new:
'''
@@ -3912,7 +3912,8 @@ before making changes to your Turtle Blocks program'))
''' Restore a turtle from its saved state '''
tid, name, xcor, ycor, heading, color, shade, pensize = blk
self.turtles.set_turtle(key)
- self.turtles.get_active_turtle().set_xy(xcor, ycor, pendown=False)
+ self.turtles.get_active_turtle().set_xy(xcor, ycor, share=True,
+ pendown=False)
self.turtles.get_active_turtle().set_heading(heading)
self.turtles.get_active_turtle().set_color(color)
self.turtles.get_active_turtle().set_shade(shade)
@@ -4077,7 +4078,7 @@ before making changes to your Turtle Blocks program'))
if btype == 'string' and blk.spr is not None:
value = blk.values[0]
if isinstance(value, unicode):
- value = value.encode('ascii', 'replace')
+ value = value.encode('utf-8')
blk.spr.set_label(value.replace('\n', RETURN))
elif btype == 'start': # block size is saved in start block
if value is not None:
@@ -4606,16 +4607,16 @@ before making changes to your Turtle Blocks program'))
if not self.interactive_mode:
return False
if isinstance(name, unicode):
- name = name.encode('ascii', 'replace')
+ name = name.encode('utf-8')
if isinstance(label, unicode):
- label = label.encode('ascii', 'replace')
+ label = label.encode('utf-8')
i = palette_name_to_index(palette)
for blk in self.palettes[i]:
blk_label = blk.spr.labels[0]
if isinstance(blk.name, unicode):
- blk.name = blk.name.encode('ascii', 'replace')
+ blk.name = blk.name.encode('utf-8')
if isinstance(blk_label, unicode):
- blk_label = blk_label.encode('ascii', 'replace')
+ blk_label = blk_label.encode('utf-8')
if blk.name == name and blk_label == label:
return True
# Check labels[1] too (e.g., store in block)
@@ -4632,7 +4633,7 @@ before making changes to your Turtle Blocks program'))
if isinstance(name, (float, int)):
return
if isinstance(name, unicode):
- name = name.encode('ascii', 'replace')
+ name = name.encode('utf-8')
if name == _('action'):
return
# Choose a palette for the new block.
@@ -4659,7 +4660,7 @@ before making changes to your Turtle Blocks program'))
if isinstance(name, (float, int)):
return
if isinstance(name, unicode):
- name = name.encode('ascii', 'replace')
+ name = name.encode('utf-8')
if name == _('my box'):
return
# Choose a palette for the new block.
@@ -4686,7 +4687,7 @@ before making changes to your Turtle Blocks program'))
if isinstance(name, (float, int)):
return
if isinstance(name, unicode):
- name = name.encode('ascii', 'replace')
+ name = name.encode('utf-8')
if name == _('my box'):
return
# Choose a palette for the new block.