Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TurtleArt
diff options
context:
space:
mode:
authorWalter Bender <walter@sugarlabs.org>2013-11-26 09:55:02 (GMT)
committer Walter Bender <walter@sugarlabs.org>2013-11-26 09:55:02 (GMT)
commit770864358ab20d94288ad95ef7f8fb4d4ea7e062 (patch)
tree4a09cc001ab6934157e13ac5e644502d735ef473 /TurtleArt
parent6675f1181529a6c893ee5c6f3244e73801f93f26 (diff)
resync with 194
Diffstat (limited to 'TurtleArt')
-rw-r--r--TurtleArt/tabasics.py14
-rw-r--r--TurtleArt/talogo.py5
-rw-r--r--TurtleArt/tapalette.py4
-rw-r--r--TurtleArt/taprimitive.py14
-rw-r--r--TurtleArt/taturtle.py1
-rw-r--r--TurtleArt/tatype.py2
-rw-r--r--TurtleArt/tawindow.py22
7 files changed, 46 insertions, 16 deletions
diff --git a/TurtleArt/tabasics.py b/TurtleArt/tabasics.py
index 3d88ce4..d66345b 100644
--- a/TurtleArt/tabasics.py
+++ b/TurtleArt/tabasics.py
@@ -198,7 +198,8 @@ turtle'))
Primitive(self.tw.lc.clear_value_blocks),
Primitive(self.tw.lc.reset_internals),
Primitive(self.tw.canvas.clearscreen),
- Primitive(self.tw.turtles.reset_turtles)
+ Primitive(self.tw.turtles.reset_turtles),
+ Primitive(self.tw.lc.active_turtle)
])]))
palette.add_block('left',
@@ -445,7 +446,8 @@ in place of a number block)'),
value_block=True,
prim_name='shade',
logo_command=':shade')
- self.tw.lc.def_prim('shade', 0, Primitive(Turtle.get_shade))
+ self.tw.lc.def_prim('shade', 0,
+ Primitive(Turtle.get_shade, return_type=TYPE_NUMBER))
palette.add_block('gray',
style='box-style',
@@ -894,7 +896,7 @@ number of seconds'))
style='clamp-style',
label=_('forever'),
prim_name='forever',
- default=[None, None],
+ default=[None],
logo_command='forever',
help_string=_('loops forever'))
self.tw.lc.def_prim(
@@ -908,7 +910,7 @@ number of seconds'))
style='clamp-style-1arg',
label=_('repeat'),
prim_name='repeat',
- default=[4, None, None],
+ default=[4, None],
logo_command='repeat',
special_name=_('repeat'),
help_string=_('loops specified number of times'))
@@ -926,7 +928,7 @@ number of seconds'))
style='clamp-style-boolean',
label=[_('if'), _('then'), ''],
prim_name='if',
- default=[None, None, None],
+ default=[None, None],
special_name=_('if then'),
logo_command='if',
help_string=_('if-then operator that uses boolean \
@@ -942,7 +944,7 @@ operators from Numbers palette'))
style='clamp-style-else',
label=[_('if'), _('then'), _('else')],
prim_name='ifelse',
- default=[None, None, None, None],
+ default=[None, None, None],
logo_command='ifelse',
special_name=_('if then else'),
help_string=_('if-then-else operator that uses \
diff --git a/TurtleArt/talogo.py b/TurtleArt/talogo.py
index 775af0f..ba76085 100644
--- a/TurtleArt/talogo.py
+++ b/TurtleArt/talogo.py
@@ -735,6 +735,11 @@ class LogoCode:
""" Stop execution of a stack """
self.procstop = True
+ def active_turtle(self):
+ ''' NOP used to add get_active_turtle to Python export '''
+ # turtle = self.tw.turtles.get_turtle()
+ pass
+
def prim_turtle(self, name):
self.tw.turtles.set_turtle(name)
diff --git a/TurtleArt/tapalette.py b/TurtleArt/tapalette.py
index 9332155..fd8fac7 100644
--- a/TurtleArt/tapalette.py
+++ b/TurtleArt/tapalette.py
@@ -176,7 +176,7 @@ class Palette():
logo_command=None, hidden=False, colors=None,
string_or_number=False):
""" Add a new block to the palette """
- block = Block(block_name)
+ block = _ProtoBlock(block_name)
block.set_style(style)
if label is not None:
block.set_label(label)
@@ -251,7 +251,7 @@ def define_logo_function(key, value):
logo_functions[key] = value
-class Block():
+class _ProtoBlock():
""" a class for defining new block primitives """
def __init__(self, name):
diff --git a/TurtleArt/taprimitive.py b/TurtleArt/taprimitive.py
index b689de5..197a8d8 100644
--- a/TurtleArt/taprimitive.py
+++ b/TurtleArt/taprimitive.py
@@ -373,7 +373,15 @@ class Primitive(object):
loop_ast = ast.While(test=condition_ast,
body=new_arg_asts[1],
orelse=[])
- return loop_ast
+ # Until always executes its body once.
+ if controller == Primitive.controller_until:
+ loop_list = []
+ for arg_ast in new_arg_asts[1]:
+ loop_list.append(arg_ast)
+ loop_list.append(loop_ast)
+ return loop_list
+ else:
+ return loop_ast
# conditionals
elif self in (LogoCode.prim_if, LogoCode.prim_ifelse):
@@ -494,6 +502,10 @@ class Primitive(object):
return [get_call_ast('logo.prim_turtle', new_arg_asts),
ast_extensions.ExtraCode(text)]
+ elif self == LogoCode.active_turtle:
+ text = 'turtle = turtles.get_active_turtle()'
+ return ast_extensions.ExtraCode(text)
+
# comment
elif self == Primitive.comment:
if isinstance(new_arg_asts[0], ast.Str):
diff --git a/TurtleArt/taturtle.py b/TurtleArt/taturtle.py
index c35125b..11336d7 100644
--- a/TurtleArt/taturtle.py
+++ b/TurtleArt/taturtle.py
@@ -653,7 +653,6 @@ class Turtle:
def draw_pixbuf(self, pixbuf, a, b, x, y, w, h, path, share=True):
''' Draw a pixbuf '''
-
self._turtles.turtle_window.canvas.draw_pixbuf(
pixbuf, a, b, x, y, w, h, self._heading)
diff --git a/TurtleArt/tatype.py b/TurtleArt/tatype.py
index 3ca47b9..0fcfc3c 100644
--- a/TurtleArt/tatype.py
+++ b/TurtleArt/tatype.py
@@ -439,5 +439,3 @@ def get_call_ast(func_name, args=None, kwargs=None, return_type=None):
else:
return TypedCall(func=func_ast, args=args, keywords=keywords,
return_type=return_type)
-
-
diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py
index c5ab0c6..81b1251 100644
--- a/TurtleArt/tawindow.py
+++ b/TurtleArt/tawindow.py
@@ -1640,10 +1640,7 @@ before making changes to your program'))
elif blk.name == 'restore':
self.restore_latest_from_trash()
elif blk.name == 'empty':
- if self.running_sugar:
- self.activity.empty_trash_alert()
- else:
- self.empty_trash()
+ self.empty_trash()
elif blk.name == 'trashall':
for b in self.just_blocks():
if b.type != 'trash':
@@ -2203,10 +2200,26 @@ before making changes to your program'))
def empty_trash(self):
''' Permanently remove all blocks presently in the trash can. '''
+ title = _('empty trash')
+ msg = _('Do you really want to empty the trash?')
+ if self.running_sugar:
+ self.activity.empty_trash_alert(title, msg)
+ else:
+ dialog = gtk.MessageDialog(None, 0, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK_CANCEL, msg)
+ dialog.set_title(title)
+ res = dialog.run()
+ dialog.destroy()
+ if res == gtk.RESPONSE_OK:
+ self._empty_trash()
+
+ def _empty_trash(self):
for blk in self.block_list.list:
if blk.type == 'trash':
blk.type = 'deleted'
blk.spr.hide()
+ for blk in self.block_list.list:
+ if blk.type == 'deleted':
+ self.block_list.list.remove(blk)
self.trash_stack = []
if 'trash' in palette_names:
self.show_toolbar_palette(palette_names.index('trash'),
@@ -3686,6 +3699,7 @@ before making changes to your program'))
self.keyboard = KEY_DICT[self.keypress]
else:
self.keyboard = 0
+ self.keypress = ''
def get_keyboard(self):
""" Return cached keyboard input """