~pythonregexp2.7/python/issue2636-11

« back to all changes in this revision

Viewing changes to Demo/tkinter/guido/hanoi.py

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-09-21 17:53:26 UTC
  • mfrom: (39025.1.14 Regexp-2.7)
  • Revision ID: darklord@timehorse.com-20080921175326-92vaej2hc3yuecxb
Merged in changes from the core Regexp branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 
36
36
        # Add background bitmap
37
37
        if bitmap:
38
 
            self.bitmap = c.create_bitmap(width/2, height/2,
 
38
            self.bitmap = c.create_bitmap(width//2, height//2,
39
39
                                          bitmap=bitmap,
40
40
                                          foreground='blue')
41
41
 
42
42
        # Generate pegs
43
43
        pegwidth = 10
44
 
        pegheight = height/2
45
 
        pegdist = width/3
46
 
        x1, y1 = (pegdist-pegwidth)/2, height*1/3
 
44
        pegheight = height//2
 
45
        pegdist = width//3
 
46
        x1, y1 = (pegdist-pegwidth)//2, height*1//3
47
47
        x2, y2 = x1+pegwidth, y1+pegheight
48
48
        self.pegs = []
49
49
        p = c.create_rectangle(x1, y1, x2, y2, fill='black')
57
57
        self.tk.update()
58
58
 
59
59
        # Generate pieces
60
 
        pieceheight = pegheight/16
61
 
        maxpiecewidth = pegdist*2/3
 
60
        pieceheight = pegheight//16
 
61
        maxpiecewidth = pegdist*2//3
62
62
        minpiecewidth = 2*pegwidth
63
63
        self.pegstate = [[], [], []]
64
64
        self.pieces = {}
65
 
        x1, y1 = (pegdist-maxpiecewidth)/2, y2-pieceheight-2
 
65
        x1, y1 = (pegdist-maxpiecewidth)//2, y2-pieceheight-2
66
66
        x2, y2 = x1+maxpiecewidth, y1+pieceheight
67
 
        dx = (maxpiecewidth-minpiecewidth) / (2*max(1, n-1))
 
67
        dx = (maxpiecewidth-minpiecewidth) // (2*max(1, n-1))
68
68
        for i in range(n, 0, -1):
69
69
            p = c.create_rectangle(x1, y1, x2, y2, fill='red')
70
70
            self.pieces[i] = p
101
101
 
102
102
        # Move it towards peg b
103
103
        bx1, by1, bx2, by2 = c.bbox(self.pegs[b])
104
 
        newcenter = (bx1+bx2)/2
 
104
        newcenter = (bx1+bx2)//2
105
105
        while 1:
106
106
            x1, y1, x2, y2 = c.bbox(p)
107
 
            center = (x1+x2)/2
 
107
            center = (x1+x2)//2
108
108
            if center == newcenter: break
109
109
            if center > newcenter: c.move(p, -1, 0)
110
110
            else: c.move(p, 1, 0)