From 0502cab7f37c9a987cb19ab89365fc68b48e5f3c Mon Sep 17 00:00:00 2001 From: Pootle daemon Date: Sat, 23 Mar 2013 04:31:15 +0000 Subject: Merge branch 'master' of git.sugarlabs.org:turtleart/mainline --- diff --git a/TurtleArt/tabasics.py b/TurtleArt/tabasics.py index 1416a61..12635ab 100644 --- a/TurtleArt/tabasics.py +++ b/TurtleArt/tabasics.py @@ -58,7 +58,7 @@ that the icons should be the same size (55x55) as the others. (This is the default icon size for Sugar toolbars.) """ -from time import time +from time import time, sleep from math import sqrt from random import uniform @@ -1180,6 +1180,7 @@ variable')) self.tw.active_turtle.show() endtime = _millisecond() + wait_time * 1000. while _millisecond() < endtime: + sleep(wait_time / 10.) yield True self.tw.active_turtle.hide() self.tw.lc.ireturn() diff --git a/TurtleArt/taexportlogo.py b/TurtleArt/taexportlogo.py index 7d7d1cb..ff3a8e6 100644 --- a/TurtleArt/taexportlogo.py +++ b/TurtleArt/taexportlogo.py @@ -89,9 +89,9 @@ def save_logo(tw): logo_command = logo_commands[blk] else: logo_command = None - if i == 0 and not logo_command in ['to stack1\r', 'to stack2\r', - 'to action', 'to start\r']: - this_stack = 'to turtleblocks_%d\r' % (stack_count) + if i == 0 and not logo_command in ['to stack1\n', 'to stack2\n', + 'to action', 'to start\n']: + this_stack = 'to turtleblocks_%d\n' % (stack_count) stack_count += 1 if logo_command in dispatch_table: if i + 1 < len(psuedocode): @@ -113,7 +113,7 @@ def save_logo(tw): this_stack += ' ' logocode += this_stack - logocode += '\rend\r' + logocode += '\nend\n' # We may need to prepend some additional procedures. for key in logo_functions.iterkeys(): @@ -124,7 +124,7 @@ def save_logo(tw): 'tasetbackground' in logocode: logocode = logo_functions['tacolor'] + logocode - logocode = 'window\r' + logocode + logocode = 'window\n' + logocode return logocode @@ -142,16 +142,16 @@ def _add_label(string): string = string[2:] string = '"' + string if string.count(' ') > 0: - return 'label sentence %s\r' % (string.replace(' ', ' "')) + return 'label sentence %s\n' % (string.replace(' ', ' "')) else: return 'label %s' % (string.replace(' ', '_')) def _add_named_stack(action): if type(action) == str and action[0:2] == '#s': - return 'to %s\r' % (str(action[2:]).replace(' ', '_')) + return 'to %s\n' % (str(action[2:]).replace(' ', '_')) else: - return 'to %s\r' % (str(action).replace(' ', '_')) + return 'to %s\n' % (str(action).replace(' ', '_')) def _add_reference_to_stack(action): @@ -265,7 +265,6 @@ def _walk_stack(tw, blk_in_stack): top = find_top_block(blk_in_stack) if blk_in_stack == top: - psuedocode = tw.lc.run_blocks(top, tw.just_blocks(), False) - return psuedocode + return tw.lc.generate_code(top, tw.just_blocks()) else: return [] diff --git a/TurtleArt/talogo.py b/TurtleArt/talogo.py index 158857a..d8adca6 100644 --- a/TurtleArt/talogo.py +++ b/TurtleArt/talogo.py @@ -22,7 +22,7 @@ #THE SOFTWARE. import gtk -from time import time +from time import time, sleep from operator import isNumberType from UserDict import UserDict @@ -188,8 +188,11 @@ class LogoCode: self.oblist[string] = sym return sym - def run_blocks(self, blk, blocks, run_flag): - """ Given a block to run... """ + def run_blocks(self, code): + self.start_time = time() + self._setup_cmd(code) + + def generate_code(self, blk, blocks): for k in self.stacks.keys(): self.stacks[k] = None self.stacks['stack1'] = None @@ -264,12 +267,7 @@ class LogoCode: if b[3] is not None: b[0].connections[-2].connections[b[3]] = b[0] - if run_flag: - # debug_output("running code: %s" % (code), self.tw.running_sugar) - self.start_time = time() - self._setup_cmd(code) - else: - return code + return code def _blocks_to_code(self, blk): """ Convert a stack of blocks to pseudocode. """ @@ -420,6 +418,7 @@ class LogoCode: self.tw.active_turtle.show() endtime = _millisecond() + self.tw.step_time * 100. while _millisecond() < endtime: + sleep(0.1) yield True self.tw.active_turtle.hide() diff --git a/TurtleArt/tautils.py b/TurtleArt/tautils.py index 0bad48a..69814c0 100644 --- a/TurtleArt/tautils.py +++ b/TurtleArt/tautils.py @@ -213,7 +213,7 @@ def get_save_name(filefilter, load_save_folder, save_file_name): gtk.FILE_CHOOSER_ACTION_SAVE, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE, gtk.RESPONSE_OK)) dialog.set_default_response(gtk.RESPONSE_OK) - if filefilter in ['.png', '.svg']: + if filefilter in ['.png', '.svg', '.lg']: suffix = filefilter else: suffix = SUFFIX[1] @@ -806,11 +806,11 @@ def power_manager_off(status): except gconf.GError: pass - _bus = dbus.SystemBus() + bus = dbus.SystemBus() try: - _proxy = _bus.get_object(OHM_SERVICE_NAME, OHM_SERVICE_PATH) - _keystore = dbus.Interface(_proxy, OHM_SERVICE_IFACE) - _keystore.SetKey('suspend.automatic_pm', bool(VALUE)) + proxy = bus.get_object(OHM_SERVICE_NAME, OHM_SERVICE_PATH) + keystore = dbus.Interface(proxy, OHM_SERVICE_IFACE) + keystore.SetKey('suspend.automatic_pm', bool(VALUE)) except dbus.exceptions.DBusException: if status: try: -- cgit v0.9.1