diff options
author | Walter Bender <walter@walter-laptop.(none)> | 2009-10-15 17:34:02 (GMT) |
---|---|---|
committer | Walter Bender <walter@walter-laptop.(none)> | 2009-10-15 17:34:02 (GMT) |
commit | 3e4b42d915b974aa67211f5c05554f3189a07c0b (patch) | |
tree | d8f1fb5ec5af4f9260a3ce8e763c14f08a585daf /cardsort.py | |
parent | ebc7e13451e394bc3fab7e5f6610d68b3f1460fe (diff) |
cleaning up solver code
Diffstat (limited to 'cardsort.py')
-rwxr-xr-x | cardsort.py | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/cardsort.py b/cardsort.py index dae14ba..88c68fe 100755 --- a/cardsort.py +++ b/cardsort.py @@ -72,7 +72,7 @@ class CardSortMain: vbox.pack_end(canvas, True, True) canvas.show() - menu_bar.append (root_menu) + menu_bar.append(root_menu) self.win.show_all() # Join the activity @@ -105,6 +105,15 @@ class CardSortMain: if self.r == 64: self.r = 0 + def _solve_cb_x(self, widget): + self.tw.grid.set_grid([8,7,6,5,4,3,2,1,0,9]) + self.tw.grid.print_grid() + + self.tw.grid.set_orientation([0,90,180,270,0,90,180,270,0,90]) + self.tw.grid.print_orientations() + sprites.redrawsprites(self.tw) + return True + def _solve_cb(self, widget): self.rotation_sets = get_rotation_sets() counter = 0 @@ -146,25 +155,8 @@ class CardSortMain: self.tw.grid.print_orientations() self.tw.win.set_title(_("CardSort") + ": " + \ _("You solved the puzzle.")) - for r in range(9): - # since we were not actually updating the graphics, - # we need to do it now - x = int((self.tw.width-\ - (self.tw.card_dim*3*self.tw.scale))/2) - y = int((self.tw.height-\ - (self.tw.card_dim*3*self.tw.scale))/2) - self.tw.grid.card_table[self.tw.grid.grid.index(r)].spr.x = x - self.tw.grid.card_table[self.tw.grid.grid.index(r)].spr.y = y - print str(r) + ": " + str(self.tw.grid.grid.index(r)) - x += int(self.tw.card_dim*self.tw.scale) - if x > (self.tw.width+(self.tw.card_dim*2*self.tw.scale))/2: - x = int((self.tw.width-\ - (self.tw.card_dim*3*self.tw.scale))/2) - y += int(self.tw.card_dim*self.tw.scale) - - self.tw.grid.card_table[self.tw.grid.grid.index(r)]\ - .set_orientation(self.rotation_sets[o][r],True) - + self.tw.grid.set_grid(g) + self.tw.grid.set_orientation(self.rotation_sets[o]) self.tw.grid.print_grid() self.tw.grid.print_orientations() sprites.redrawsprites(self.tw) |