From a91b6c55f4185be1265a9dee43c14d2bbcffff64 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Wed, 27 Jan 2010 23:25:04 +0000 Subject: more *turtle improvements --- diff --git a/talogo.py b/talogo.py index ef276a1..ae661c6 100644 --- a/talogo.py +++ b/talogo.py @@ -618,9 +618,9 @@ def display_coordinates(tw, a=-1, b=-1, d=-1): if hasattr(tw, "activity"): if hasattr(tw.activity, "coordinates_label"): if a==-1 and b==-1 and d == -1: - x = round_int(tw.turtle.xcor/tw.coord_scale) - y = round_int(tw.turtle.ycor/tw.coord_scale) - h = round_int(tw.turtle.heading) + x = round_int(tw.canvas.xcor/tw.coord_scale) + y = round_int(tw.canvas.ycor/tw.coord_scale) + h = round_int(tw.canvas.heading) else: x = a y = b diff --git a/taproject.py b/taproject.py index ffbe064..7bbd057 100644 --- a/taproject.py +++ b/taproject.py @@ -99,7 +99,6 @@ def _json_load(text): else: io = StringIO(text) listdata = jload(io) - print "load files: %s" % (listdata) # json converts tuples to lists, so we need to convert back, return _tuplify(listdata) @@ -128,30 +127,23 @@ def _tuplify(t): return tuple(map(_tuplify, t)) def read_data(tw, data): - print "data is %d elements long" % (len(data)) # First we create the blocks blocks = [] t = 0 for b in data: - print b if b[1] == 'turtle': load_turtle(tw, b) - print "we founf a turtle" t = 1 else: blk = load_block(tw, b); blocks.append(blk) - print "we have %d blocks and %d turtles" % (len(blocks), t) # Then we make the connections for i in range(len(blocks)): - print "connections for %s are:" % (blocks[i].name) cons=[] for c in data[i][4]: if c is None: cons.append(None) - print " None" else: cons.append(blocks[c]) - print " %s" % (blocks[c].name) blocks[i].connections = cons # Then we need to adjust the x,y positions, as block sizes may have changed for b in blocks: @@ -177,7 +169,6 @@ def load_block(tw, b): else: labels = [label] - print labels """ # TODO: handle media if btype == 'journal' or btype == 'audiooff' or btype == 'descriptionoff': @@ -271,7 +262,6 @@ def _assemble_data_to_save(tw, save_turtle=True): for i, b in enumerate(tw._just_blocks()): b.id = i for b in tw._just_blocks(): - print "saving: %d %s %s" % (b.id, b.name, b.spr.labels[0]) name = (b.name, b.spr.labels[0]) """ if tw.defdict.has_key(name) or name in nolabel: @@ -284,7 +274,6 @@ def _assemble_data_to_save(tw, save_turtle=True): connections = [get_id(c) for c in b.connections] else: connections = None - print connections (sx, sy) = b.spr.get_xy() data.append((b.id, name, sx-tw.canvas.cx, sy-tw.canvas.cy, connections)) if save_turtle is True: diff --git a/tawindow.py b/tawindow.py index 0abe047..caf0fa4 100644 --- a/tawindow.py +++ b/tawindow.py @@ -315,9 +315,11 @@ class TurtleArtWindow(): """ Show/hide turtle palettes """ - def hide_toolbar_palette(self, hide_palette_spr=True): - for i in range(len(PALETTES[self.selected_palette])): - self.palettes[self.selected_palette][i].spr.set_layer(HIDE_LAYER) + def hide_toolbar_palette(self): + if self.selected_palette is not None: + for i in range(len(PALETTES[self.selected_palette])): + self.palettes[self.selected_palette][i].spr.set_layer( + HIDE_LAYER) for i in range(len(PALETTES)): self.selectors[i].set_layer(HIDE_LAYER) if self.palette_sprs[i] is not None: @@ -350,7 +352,7 @@ class TurtleArtWindow(): return if self.selected_palette is not None: - self.hide_toolbar_palette(False) + self.hide_toolbar_palette() if self.palette_sprs[n] is not None: self.palette_sprs[n].set_layer(CATEGORY_LAYER) -- cgit v0.9.1