From 29a05850d56fb53420d1b995bde050ef5a957739 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Mon, 25 Jan 2010 04:26:02 +0000 Subject: fixed dock problem with flow --- diff --git a/block.py b/block.py index 65cd563..293ee01 100644 --- a/block.py +++ b/block.py @@ -147,14 +147,8 @@ class Block: self.spr.set_label_attributes(9, True, "right", "top", i) elif i == 2: # bottom self.spr.set_label_attributes(9, True, "right", "bottom", i) - - # make sure the label fits - lw = self.spr.label_width() - lwh = self.spr.label_area_dimensions() - if lw > lwh[0]: - e = lw-lwh[0] - self._make_block(e, svg) - self.spr.set_shape(self.shape) + # make sure labels fit + self.resize() def _make_block(self, e, svg): self._set_colors(svg) @@ -216,8 +210,8 @@ class Block: def _make_basic_style(self, e, svg): self.svg.expand(40+e, 0) self._make_basic_block(svg) - self.docks = (('flow', True, self.svg.docks[0][0], self.svg.docks[0][1]), - ('flow', False,self.svg.docks[1][0], self.svg.docks[1][1])) + self.docks = (('flow',True,self.svg.docks[0][0],self.svg.docks[0][1]), + ('flow',False,self.svg.docks[1][0],self.svg.docks[1][1])) self._left, self._right = 0, 0 def _make_basic_style_head(self, e, svg): @@ -226,7 +220,8 @@ class Block: self.svg.set_cap(True) self._make_basic_block(svg) self.docks = (('start', True, 0, 0), - ('flow', False, self.svg.docks[0][0], self.svg.docks[0][1])) + ('flow', False, self.svg.docks[0][0], + self.svg.docks[0][1])) self._left, self._right = 0, 0 def _make_basic_style_head_1arg(self, e, svg): @@ -236,40 +231,51 @@ class Block: self.svg.set_cap(True) self._make_basic_block(svg) self.docks = (('start', True, 0, 0), - ('string', False, self.svg.docks[0][0], self.svg.docks[0][1]), - ('flow', False, self.svg.docks[1][0], self.svg.docks[1][1])) + ('string', False, self.svg.docks[0][0], + self.svg.docks[0][1]), + ('flow', False, self.svg.docks[1][0], + self.svg.docks[1][1])) self._left, self._right = 0, self.svg.get_innie_width() def _make_basic_style_tail(self, e, svg): self.svg.expand(40+e, 0) self.svg.set_tab(False) self._make_basic_block(svg) - self.docks = (('flow', True, self.svg.docks[0][0], self.svg.docks[0][1]), + self.docks = (('flow', True, self.svg.docks[0][0], + self.svg.docks[0][1]), ('unavailable', False, 0, 0)) def _make_basic_style_1arg(self, e, svg): self.svg.expand(25+e, 0) self.svg.set_innie([True]) self._make_basic_block(svg) - self.docks = (('flow', True, self.svg.docks[0][0], self.svg.docks[0][1]), - ('number', False, self.svg.docks[1][0], self.svg.docks[1][1]), - ('flow', False, self.svg.docks[2][0], self.svg.docks[2][1])) + self.docks = (('flow', True, self.svg.docks[0][0], + self.svg.docks[0][1]), + ('number', False, self.svg.docks[1][0], + self.svg.docks[1][1]), + ('flow', False, self.svg.docks[2][0], + self.svg.docks[2][1])) self._left, self._right = 0, self.svg.get_innie_width() def _make_basic_style_2arg(self, e, svg): self.svg.expand(25+e, 0) self.svg.set_innie([True,True]) self._make_basic_block(svg) - self.docks = (('flow', True, self.svg.docks[0][0], self.svg.docks[0][1]), - ('number', False, self.svg.docks[1][0], self.svg.docks[1][1]), - ('number', False, self.svg.docks[2][0], self.svg.docks[2][1]), - ('flow', False, self.svg.docks[3][0], self.svg.docks[3][1])) + self.docks = (('flow', True, self.svg.docks[0][0], + self.svg.docks[0][1]), + ('number', False, self.svg.docks[1][0], + self.svg.docks[1][1]), + ('number', False, self.svg.docks[2][0], + self.svg.docks[2][1]), + ('flow', False, self.svg.docks[3][0], + self.svg.docks[3][1])) self._left, self._right = 0, self.svg.get_innie_width()*1.5 def _make_box_style(self, e, svg): self.svg.expand(60+e, 0) self._make_basic_box(svg) - self.docks = (('number', True, self.svg.docks[0][0], self.svg.docks[0][1]), + self.docks = (('number', True, self.svg.docks[0][0], + self.svg.docks[0][1]), ('unavailable', False, 0, 0)) self._left, self._right = self.svg.docks[1][0], 0 @@ -285,9 +291,12 @@ class Block: The "outie" is added last, so the dock order in the NUMBER_STYLE needs to be modified. """ - self.docks = (('number', True, self.svg.docks[2][0], self.svg.docks[2][1]), - ('number', False, self.svg.docks[0][0], self.svg.docks[0][1]), - ('number', False, self.svg.docks[1][0], self.svg.docks[1][1])) + self.docks = (('number', True, self.svg.docks[2][0], + self.svg.docks[2][1]), + ('number', False, self.svg.docks[0][0], + self.svg.docks[0][1]), + ('number', False, self.svg.docks[1][0], + self.svg.docks[1][1])) self._left, self._right = self.svg.docks[2][0], 0 def _make_number_style_1arg(self, e, svg): @@ -297,8 +306,10 @@ class Block: self.svg.set_tab(False) self.svg.set_slot(False) self._make_basic_block(svg) - self.docks = (('number', True, self.svg.docks[1][0], self.svg.docks[1][1]), - ('number', False, self.svg.docks[0][0], self.svg.docks[0][1])) + self.docks = (('number', True, self.svg.docks[1][0], + self.svg.docks[1][1]), + ('number', False, self.svg.docks[0][0], + self.svg.docks[0][1])) self._left, self._right = self.svg.docks[1][0], self.svg.docks[1][0] def _make_number_style_porch(self, e, svg): @@ -309,33 +320,45 @@ class Block: self.svg.set_slot(False) self.svg.set_porch(True) self._make_basic_block(svg) - self.docks = (('number', True, self.svg.docks[2][0], self.svg.docks[2][1]), - ('number', False, self.svg.docks[0][0], self.svg.docks[0][1]), - ('number', False, self.svg.docks[1][0], self.svg.docks[1][1])) + self.docks = (('number', True, self.svg.docks[2][0], + self.svg.docks[2][1]), + ('number', False, self.svg.docks[0][0], + self.svg.docks[0][1]), + ('number', False, self.svg.docks[1][0], + self.svg.docks[1][1])) self._left = self.svg.docks[2][0] self._right = self.svg.get_width()-self.svg.docks[0][0] def _make_compare_style(self, e, svg): self.svg.expand(10+e,0) self._make_boolean_compare(svg) - self.docks = (('bool', True, self.svg.docks[0][0], self.svg.docks[0][1]), - ('number', False, self.svg.docks[1][0], self.svg.docks[1][1]), - ('number', False, self.svg.docks[2][0], self.svg.docks[2][1])) + self.docks = (('bool', True, self.svg.docks[0][0], + self.svg.docks[0][1], '('), + ('number', False, self.svg.docks[1][0], + self.svg.docks[1][1]), + ('number', False, self.svg.docks[2][0], + self.svg.docks[2][1]), + ('unavailable', False, 0, 0, ')')) self._left, self._right = self.svg.get_width()-self.svg.docks[2][0], 0 def _make_boolean_style(self, e, svg): self.svg.expand(10+e,0) self._make_boolean_and_or(svg) - self.docks = (('bool', True, self.svg.docks[0][0], self.svg.docks[0][1]), - ('bool', False, self.svg.docks[1][0], self.svg.docks[1][1]), - ('bool', False, self.svg.docks[2][0], self.svg.docks[2][1])) + self.docks = (('bool', True, self.svg.docks[0][0], + self.svg.docks[0][1]), + ('bool', False, self.svg.docks[1][0], + self.svg.docks[1][1]), + ('bool', False, self.svg.docks[2][0], + self.svg.docks[2][1])) self._left, self._right = self.svg.get_width()-self.svg.docks[1][0], 0 def _make_not_style(self, e, svg): self.svg.expand(15+e, 0) self._make_boolean_not(svg) - self.docks = (('bool', True, self.svg.docks[0][0], self.svg.docks[0][1]), - ('bool', False, self.svg.docks[1][0], self.svg.docks[1][1])) + self.docks = (('bool', True, self.svg.docks[0][0], + self.svg.docks[0][1]), + ('bool', False, self.svg.docks[1][0], + self.svg.docks[1][1])) self._right = self.svg.get_width()-self.svg.docks[1][0] self._left = self._right @@ -343,8 +366,11 @@ class Block: self.svg.expand(25+e, 0) self.svg.set_slot(True) self._make_basic_flow(svg) - self.docks = (('flow', True, self.svg.docks[0][0], self.svg.docks[0][1]), - ('flow', False, self.svg.docks[1][0], self.svg.docks[1][1])) + self.docks = (('flow', True, self.svg.docks[0][0], + self.svg.docks[0][1]), + ('flow', False, self.svg.docks[1][0], + self.svg.docks[1][1], '['), + ('unavailable', False, 0, 0, ']')) self._left, self._right = 0, self.svg.get_width()-self.svg.docks[1][0] def _make_flow_style_1arg(self, e, svg): @@ -353,10 +379,14 @@ class Block: self.svg.set_tab(True) self.svg.set_innie([True]) self._make_basic_flow(svg) - self.docks = (('flow', True, self.svg.docks[0][0], self.svg.docks[0][1]), - ('number', False, self.svg.docks[1][0], self.svg.docks[1][1]), - ('flow', False, self.svg.docks[2][0], self.svg.docks[2][1]), - ('flow', False, self.svg.docks[3][0], self.svg.docks[3][1])) + self.docks = (('flow', True, self.svg.docks[0][0], + self.svg.docks[0][1]), + ('number', False, self.svg.docks[1][0], + self.svg.docks[1][1]), + ('flow', False, self.svg.docks[2][0], + self.svg.docks[2][1], '['), + ('flow', False, self.svg.docks[3][0], + self.svg.docks[3][1], ']')) self._left, self._right = 0, self.svg.get_width()-self.svg.docks[1][0] def _make_flow_style_boolean(self, e, svg): @@ -365,10 +395,14 @@ class Block: self.svg.set_tab(True) self.svg.set_boolean(True) self._make_basic_flow(svg) - self.docks = (('flow', True, self.svg.docks[0][0], self.svg.docks[0][1]), - ('bool', False, self.svg.docks[1][0], self.svg.docks[1][1]), - ('flow', False, self.svg.docks[2][0], self.svg.docks[2][1]), - ('flow', False, self.svg.docks[3][0], self.svg.docks[3][1])) + self.docks = (('flow', True, self.svg.docks[0][0], + self.svg.docks[0][1]), + ('bool', False, self.svg.docks[1][0], + self.svg.docks[1][1]), + ('flow', False, self.svg.docks[2][0], + self.svg.docks[2][1], '['), + ('flow', False, self.svg.docks[3][0], + self.svg.docks[3][1], ']')) self._left, self._right = 0, self.svg.get_width()-self.svg.docks[1][0] def _make_basic_block(self, svg): diff --git a/talogo.py b/talogo.py index 96ebd61..325f8bc 100644 --- a/talogo.py +++ b/talogo.py @@ -41,11 +41,9 @@ class taLogo: pass from taturtle import * from tagplay import * from tajail import * - -from gettext import gettext as _ - from constants import * +from gettext import gettext as _ procstop = False @@ -65,6 +63,14 @@ class logoerror(Exception): return repr(self.value) def run_blocks(lc, blk, blocks, run_flag): + print "run blocks %s" % (blk.name) + for b in blocks: + print " %s" % (b.name) + for c in b.connections: + if c == None: + print " None" + else: + print " %s" % (c.name) # user-defined stacks for x in lc.stacks.keys(): lc.stacks[x]= None @@ -87,13 +93,14 @@ def run_blocks(lc, blk, blocks, run_flag): else: return code def blocks_to_code(lc, blk): - if blk is None: + if blk==None: return ['%nothing%'] spr = blk.spr code = [] dock = blk.docks[0] - if len(dock)>4: code.append(dock[4]) - if blk.primitive is not None: + if len(dock)>4: + code.append(dock[4]) + if blk.primitive != None: code.append(blk.primitive) else: if blk.name=='number': @@ -130,10 +137,12 @@ def blocks_to_code(lc, blk): b = blk.connections[i] dock = blk.docks[i] if len(dock)>4: - for c in dock[4]: code.append(c) - if b is not None: + for c in dock[4]: + code.append(c) + if b != None: code.extend(blocks_to_code(lc, b)) elif blk.docks[i][0] not in ['flow', 'unavailable']: + print "appending nothing" code.append('%nothing%') return code @@ -169,8 +178,7 @@ def setup_cmd(lc, str): lc.step = start_eval(lc, list) def start_eval(lc, list): - icall(lc, evline, list) - yield True + icall(lc, evline, list); yield True # turn off stop icon when execution is finished if hasattr(lc.tw,"activity"): lc.tw.activity.stop_button.set_icon("stopitoff") @@ -188,13 +196,13 @@ def evline(lc, list): yield True lc.tw.turtle.spr.set_layer(HIDE_LAYER) token = lc.iline[0] - if token is lc.symopar: - token=lc.iline[1] - icall(lc, eval) - yield True + if token == lc.symopar: + token = lc.iline[1] + icall(lc, eval); yield True if lc.procstop: break - if lc.iresult==None: continue + if lc.iresult == None: + continue raise logoerror(str(lc.iresult)) lc.iline = oldiline ireturn(lc) @@ -203,7 +211,7 @@ def evline(lc, list): def eval(lc, infixarg=False): token = lc.iline.pop(0) - if type(token) is lc.symtype: + if type(token) == lc.symtype: icall(lc, evalsym, token); yield True res = lc.iresult else: res = token @@ -219,25 +227,22 @@ def evalsym(lc, token): undefined_check(lc, token) oldcfun, oldarglist = lc.cfun, lc.arglist lc.cfun, lc.arglist = token, [] - if token.nargs is None: + if token.nargs == None: raise logoerror("#noinput") for i in range(token.nargs): no_args_check(lc) - icall(lc, eval) - yield True + icall(lc, eval); yield True lc.arglist.append(lc.iresult) if lc.cfun.rprim: - if type(lc.cfun.fcn) is lc.listtype: - icall(lc, ufuncall, cfun.fcn) - yield True + if type(lc.cfun.fcn) == lc.listtype: + icall(lc, ufuncall, cfun.fcn); yield True else: - icall(lc, lc.cfun.fcn, *lc.arglist) - yield True + icall(lc, lc.cfun.fcn, *lc.arglist); yield True result = None else: result = lc.cfun.fcn(lc, *lc.arglist) lc.cfun, lc.arglist = oldcfun, oldarglist - if lc.arglist is not None and result is None: + if lc.arglist != None and result == None: raise logoerror("%s didn't output to %s (arglist %s, result %s)" % \ (oldcfun.name, lc.cfun.name, str(lc.arglist), str(result))) ireturn(lc, result) @@ -248,18 +253,16 @@ def evalinfix(lc, firstarg): oldcfun, oldarglist = lc.cfun, lc.arglist lc.cfun, lc.arglist = token, [firstarg] no_args_check(lc) - icall(lc, eval, True) - yield True + icall(lc, eval, True); yield True lc.arglist.append(lc.iresult) result = lc.cfun.fcn(lc,*lc.arglist) lc.cfun, lc.arglist = oldcfun, oldarglist - ireturn (lc,result) - yield True + ireturn (lc,result); yield True def infixnext(lc): if len(lc.iline)==0: return False - if type(lc.iline[0]) is not lc.symtype: + if type(lc.iline[0]) != lc.symtype: return False return lc.iline[0].name in ['+', '-', '*', '/','%','and','or'] @@ -667,7 +670,7 @@ def loadmyblock(lc,x): def callmyfunc(lc, f, x): y = myfunc(lc, f, x) - if y is None: + if y == None: raise logoerror("#syntaxerror") stop_logo(lc.tw) else: diff --git a/tawindow.py b/tawindow.py index 0f510d3..effad0c 100644 --- a/tawindow.py +++ b/tawindow.py @@ -232,59 +232,6 @@ class TurtleArtWindow(): self._run_stack(blk) return - """ - button_press - """ - def button_press(self, mask, x, y, verbose=False): - if verbose: - print "processing remote button press: " + str(x) + " " + str(y) - self.block_operation = 'click' - - # Unselect things that may have been selected earlier - if self.selected_blk is not None: - self._unselect_block() - self.selected_turtle = None - # Always hide the status layer on a click - self.status_spr.set_layer(HIDE_LAYER) - - # Find out what was clicked - spr = self.sprite_list.find_sprite((x,y)) - self.x, self.y = x, y - self.dx = 0 - self.dy = 0 - if spr is None: - return True - self.selected_spr = spr - - # From the sprite at x, y, look for a corresponding block - blk = self.block_list.spr_to_block(spr) - if blk is not None: - print "button press: found %s at (%d,%d)" % (blk.name, x, y) - # TODO: we can check here for type block vs type proto - self.selected_blk = blk - self._block_pressed(mask, x, y, blk) - return True - - # Next, look for a turtle - tur = self.turtle_list.spr_to_turtle(spr) - if tur is not None: - print "button press: found turtle at (%d,%d)" % (x, y) - self.selected_turtle = tur - self._turtle_pressed(x,y) - return True - - # Finally, check for anything else - if hasattr(spr, 'type'): - # TODO: eliminate remaining dependencies on spr.type - print "button press on spr type: %s" % (spr.type) - if spr.type == "canvas": - spr.set_layer(CANVAS_LAYER) - return True - elif spr.type == 'selbutton': - self._select_category(spr) - elif spr.type == 'category': - self._block_selector_pressed(x,y) - # # Internal methods # @@ -304,6 +251,13 @@ class TurtleArtWindow(): self.window.connect("key_press_event", self._keypress_cb) """ + Repaint + """ + def _expose_cb(self, win, event): + self.sprite_list.redraw_sprites() + return True + + """ Are we running from within Sugar? """ def _running_sugar(self): @@ -319,34 +273,6 @@ class TurtleArtWindow(): os.path.exists('/sys/power/olpc-pm') """ - Block pressed - """ - def _block_pressed(self, mask, x, y, blk): - if blk is not None: - print "in block_pressed: %s" % (blk.name) - print "0. marking block %s as selected" % (blk.name) - blk.spr.set_shape(blk.selected_shape) - print "1. disconnecting block %s from those above it" % (blk.name) - self._disconnect(blk) - print "2. creating drag_group with %s" % (blk.name) - self.drag_group = self._find_group(blk) - print "drag_group: %s" % (self._print_blk_list(self.drag_group)) - for blk in self.drag_group: - blk.spr.set_layer(TOP_LAYER) - (sx, sy) = blk.spr.get_xy() - self.dragpos = x-sx, y-sy - - """ - Unselect block - """ - def _unselect_block(self): - # After unselecting a 'number' block, we need to check its value - if self.selected_blk.name == 'number': - self._number_check() - # Reset shape of the selected block - self.selected_blk.spr.set_shape(self.selected_blk.shape) - - """ Select a category. TODO: move to toolbar """ @@ -418,30 +344,30 @@ class TurtleArtWindow(): Mouse move """ def _move_cb(self, win, event): - x,y = self.xy(event) + x, y = self.xy(event) self._mouse_move(x, y) return True def _mouse_move(self, x, y, verbose=False, mdx=0, mdy=0): if verbose: - print "processing remote mouse move: " + str(x) + " " + str(y) + print "processing remote mouse move: %d, %d" % (x, y) self.block_operation = 'move' # First, check to see if we are dragging or rotating a turtle. if self.selected_turtle is not None: type,dragx,dragy = self.dragpos - (sx,sy) = self.selected_turtle.spr.get_xy() + (sx, sy) = self.selected_turtle.spr.get_xy() if type == 'move': if mdx != 0 or mdy != 0: - dx,dy = mdx,mdy + dx, dy = mdx, mdy else: - dx,dy = x-dragx-sx,y-dragy-sy + dx, dy = x-dragx-sx, y-dragy-sy self.selected_turtle.spr.move((sx+dx, sy+dy)) else: if mdx != 0 or mdy != 0: - dx,dy = mdx,mdy + dx, dy = mdx, mdy else: - dx,dy = x-sx-30,y-sy-30 + dx, dy = x-sx-30, y-sy-30 seth(self.turtle, int(dragx+atan2(dy,dx)/DEGTOR+5)/10*10) # If we are hoving, show popup help. elif self.drag_group is None: @@ -453,10 +379,10 @@ class TurtleArtWindow(): self.selected_spr = blk.spr dragx, dragy = self.dragpos if mdx != 0 or mdy != 0: - dx,dy = mdx,mdy + dx, dy = mdx, mdy else: (sx,sy) = blk.spr.get_xy() - dx,dy = x-dragx-sx,y-dragy-sy + dx, dy = x-dragx-sx, y-dragy-sy # Take no action if there was a move of 0,0. if dx == 0 and dy == 0: return @@ -471,7 +397,7 @@ class TurtleArtWindow(): (bx, by) = b.spr.get_xy() b.spr.move((bx+dx, by+dy)) if mdx != 0 or mdy != 0: - dx,dy = 0,0 + dx, dy = 0, 0 else: self.dx += dx self.dy += dy @@ -585,7 +511,7 @@ class TurtleArtWindow(): if keyname is None: return False if verbose: - print "processing remote key press: " + keyname + print "processing remote key press: %s" % (keyname) self.keypress = keyname @@ -723,30 +649,107 @@ class TurtleArtWindow(): return True """ + button_press + """ + def button_press(self, mask, x, y, verbose=False): + if verbose: + print "processing remote button press: %d, %d" % (x, y) + self.block_operation = 'click' + + # Unselect things that may have been selected earlier + if self.selected_blk is not None: + self._unselect_block() + self.selected_turtle = None + # Always hide the status layer on a click + self.status_spr.set_layer(HIDE_LAYER) + + # Find out what was clicked + spr = self.sprite_list.find_sprite((x,y)) + self.dx = 0 + self.dy = 0 + if spr is None: + return True + self.selected_spr = spr + + # From the sprite at x, y, look for a corresponding block + blk = self.block_list.spr_to_block(spr) + if blk is not None: + print "button press: found %s at (%d,%d)" % (blk.name, x, y) + # TODO: we can check here for type block vs type proto + self.selected_blk = blk + self._block_pressed(mask, x, y, blk) + return True + + # Next, look for a turtle + tur = self.turtle_list.spr_to_turtle(spr) + if tur is not None: + print "button press: found turtle at (%d,%d)" % (x, y) + self.selected_turtle = tur + self._turtle_pressed(x, y) + return True + + # Finally, check for anything else + if hasattr(spr, 'type'): + # TODO: eliminate remaining dependencies on spr.type + print "button press on spr type: %s" % (spr.type) + if spr.type == "canvas": + spr.set_layer(CANVAS_LAYER) + return True + elif spr.type == 'selbutton': + self._select_category(spr) + elif spr.type == 'category': + self._block_selector_pressed(x,y) + + """ + Block pressed + """ + def _block_pressed(self, mask, x, y, blk): + if blk is not None: + print "in block_pressed: %s" % (blk.name) + print "0. marking block %s as selected" % (blk.name) + blk.spr.set_shape(blk.selected_shape) + print "1. disconnecting block %s from those above it" % (blk.name) + self._disconnect(blk) + print "2. creating drag_group with %s" % (blk.name) + self.drag_group = self._find_group(blk) + print "drag_group: %s" % (self._print_blk_list(self.drag_group)) + for blk in self.drag_group: + blk.spr.set_layer(TOP_LAYER) + (sx, sy) = blk.spr.get_xy() + self.dragpos = x-sx, y-sy + + """ + Unselect block + """ + def _unselect_block(self): + # After unselecting a 'number' block, we need to check its value + if self.selected_blk.name == 'number': + self._number_check() + # Reset shape of the selected block + self.selected_blk.spr.set_shape(self.selected_blk.shape) + self.selected_blk = None + + """ Button Press """ def _buttonpress_cb(self, win, event): self.window.grab_focus() x, y = self.xy(event) self.button_press(event.get_state()>k.gdk.CONTROL_MASK, x, y) - - # if sharing, send button press if self._sharing(): - # print "sending button pressed" if event.get_state()>k.gdk.CONTROL_MASK is True: - self.activity._send_event("p:"+str(x)+":"+str(y)+":"+'T') + self.activity._send_event("p:%d:%d:T" % (x, y)) else: - self.activity._send_event("p:"+str(x)+":"+str(y)+":"+'F') + self.activity._send_event("p:%d:%d:F" % (x, y)) return True """ Button release """ def _buttonrelease_cb(self, win, event): - x,y = self.xy(event) + x, y = self.xy(event) self.button_release(x, y) if self._sharing(): - # print "sending release button" self.activity._send_event("r:"+str(x)+":"+str(y)) return True @@ -758,13 +761,10 @@ class TurtleArtWindow(): self.activity._send_event("m:%d:%d" % (self.dx, self.dy)) self.dx = 0 self.dy = 0 - - print "button release" if verbose: - print "processing remote button release: " + str(x) + " " + str(y) + print "processing remote button release: %d, %d" % (x, y) # We may have been moving the turtle if self.selected_turtle is not None: - print "clicked on a turtle" (tx, ty) = self.turtle.spr.get_xy() self.turtle.xcor = tx-self.turtle.cx- \ self.turtle.canvas._width/2+30 @@ -823,13 +823,6 @@ class TurtleArtWindow(): self._run_stack(blk) """ - Repaint - """ - def _expose_cb(self, win, event): - self.sprite_list.redraw_sprites() - return True - - """ snap_to_dock """ def _snap_to_dock(self): @@ -858,14 +851,9 @@ class TurtleArtWindow(): blk_in_dock = best_you.connections[best_your_dockn] if blk_in_dock is not None: for blk in self._find_group(blk_in_dock): - print "hiding blk %s" % (blk.name) blk.spr.hide() - print "connecting %s to %s, position %d" %\ - (my_block.name, best_you.name, best_your_dockn) best_you.connections[best_your_dockn] = my_block if my_block.connections is not None: - print "connecting %s to %s, position %d" %\ - (best_you.name, my_block.name, best_my_dockn) my_block.connections[best_my_dockn] = best_you """ @@ -937,8 +925,6 @@ class TurtleArtWindow(): newspr.set_layer(TOP_LAYER) self.dragpos = 20, 20 newblk.connections = [None]*len(newblk.docks) - print newblk.defaults - print newblk.docks for i, argvalue in enumerate(newblk.defaults): # skip the first dock position--it is always a connector dock = newblk.docks[i+1] @@ -990,9 +976,7 @@ class TurtleArtWindow(): def _disconnect(self, blk): if blk.connections[0]==None: return - print "disconnecting %s" % (blk.name) blk2=blk.connections[0] - print "from %s" % (blk2.name) blk2.connections[blk2.connections.index(blk)] = None blk.connections[0] = None -- cgit v0.9.1