diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2008-09-13 01:43:28 (GMT) |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2008-09-13 01:43:28 (GMT) |
commit | 2a9b9cbea08c7c22a328926b0e0719fb197743a0 (patch) | |
tree | 51c8930c097a35c97db9cdae6f5af889424cf9bd /Demo/tkinter | |
parent | e91fcbdf691c687d1195fad342564e0b3442f444 (diff) | |
download | cpython-2a9b9cbea08c7c22a328926b0e0719fb197743a0.zip cpython-2a9b9cbea08c7c22a328926b0e0719fb197743a0.tar.gz cpython-2a9b9cbea08c7c22a328926b0e0719fb197743a0.tar.bz2 |
#687648 from Robert Schuppenies: use classic division.
Diffstat (limited to 'Demo/tkinter')
-rwxr-xr-x | Demo/tkinter/guido/hanoi.py | 20 | ||||
-rwxr-xr-x | Demo/tkinter/guido/solitaire.py | 4 | ||||
-rw-r--r-- | Demo/tkinter/guido/sortvisu.py | 10 |
3 files changed, 17 insertions, 17 deletions
diff --git a/Demo/tkinter/guido/hanoi.py b/Demo/tkinter/guido/hanoi.py index 078c246..58ba1d1 100755 --- a/Demo/tkinter/guido/hanoi.py +++ b/Demo/tkinter/guido/hanoi.py @@ -35,15 +35,15 @@ class Tkhanoi: # Add background bitmap if bitmap: - self.bitmap = c.create_bitmap(width/2, height/2, + self.bitmap = c.create_bitmap(width//2, height//2, bitmap=bitmap, foreground='blue') # Generate pegs pegwidth = 10 - pegheight = height/2 - pegdist = width/3 - x1, y1 = (pegdist-pegwidth)/2, height*1/3 + pegheight = height//2 + pegdist = width//3 + x1, y1 = (pegdist-pegwidth)//2, height*1//3 x2, y2 = x1+pegwidth, y1+pegheight self.pegs = [] p = c.create_rectangle(x1, y1, x2, y2, fill='black') @@ -57,14 +57,14 @@ class Tkhanoi: self.tk.update() # Generate pieces - pieceheight = pegheight/16 - maxpiecewidth = pegdist*2/3 + pieceheight = pegheight//16 + maxpiecewidth = pegdist*2//3 minpiecewidth = 2*pegwidth self.pegstate = [[], [], []] self.pieces = {} - x1, y1 = (pegdist-maxpiecewidth)/2, y2-pieceheight-2 + x1, y1 = (pegdist-maxpiecewidth)//2, y2-pieceheight-2 x2, y2 = x1+maxpiecewidth, y1+pieceheight - dx = (maxpiecewidth-minpiecewidth) / (2*max(1, n-1)) + dx = (maxpiecewidth-minpiecewidth) // (2*max(1, n-1)) for i in range(n, 0, -1): p = c.create_rectangle(x1, y1, x2, y2, fill='red') self.pieces[i] = p @@ -101,10 +101,10 @@ class Tkhanoi: # Move it towards peg b bx1, by1, bx2, by2 = c.bbox(self.pegs[b]) - newcenter = (bx1+bx2)/2 + newcenter = (bx1+bx2)//2 while 1: x1, y1, x2, y2 = c.bbox(p) - center = (x1+x2)/2 + center = (x1+x2)//2 if center == newcenter: break if center > newcenter: c.move(p, -1, 0) else: c.move(p, 1, 0) diff --git a/Demo/tkinter/guido/solitaire.py b/Demo/tkinter/guido/solitaire.py index 50a8b26..1c1105c 100755 --- a/Demo/tkinter/guido/solitaire.py +++ b/Demo/tkinter/guido/solitaire.py @@ -168,7 +168,7 @@ class Card: self.group = Group(canvas) text = "%s %s" % (VALNAMES[value], suit) - self.__text = CanvasText(canvas, CARDWIDTH/2, 0, + self.__text = CanvasText(canvas, CARDWIDTH//2, 0, anchor=N, fill=self.color, text=text) self.group.addtag_withtag(self.__text) @@ -589,7 +589,7 @@ class Solitaire: def animatedmoveto(self, card, dest): for i in range(10, 0, -1): - dx, dy = (dest.x-card.x)/i, (dest.y-card.y)/i + dx, dy = (dest.x-card.x)//i, (dest.y-card.y)//i card.moveby(dx, dy) self.master.update_idletasks() diff --git a/Demo/tkinter/guido/sortvisu.py b/Demo/tkinter/guido/sortvisu.py index f18f2c1..9148b73 100644 --- a/Demo/tkinter/guido/sortvisu.py +++ b/Demo/tkinter/guido/sortvisu.py @@ -88,7 +88,7 @@ class Array: if self.speed == "fastest": msecs = 0 elif self.speed == "fast": - msecs = msecs/10 + msecs = msecs//10 elif self.speed == "single-step": msecs = 1000000000 if not self.stop_mainloop: @@ -320,7 +320,7 @@ class ArrayItem: return outcome def position(self): - x1 = (self.index+1)*XGRID - WIDTH/2 + x1 = (self.index+1)*XGRID - WIDTH//2 x2 = x1+WIDTH y2 = (self.array.maxvalue+1)*YGRID y1 = y2 - (self.value)*YGRID @@ -349,7 +349,7 @@ def interpolate(oldpts, newpts, n): res = [tuple(oldpts)] for i in range(1, n): for k in range(len(pts)): - pts[k] = oldpts[k] + (newpts[k] - oldpts[k])*i/n + pts[k] = oldpts[k] + (newpts[k] - oldpts[k])*i//n res.append(tuple(pts)) res.append(tuple(newpts)) return res @@ -359,7 +359,7 @@ def interpolate(oldpts, newpts, n): def uniform(array): size = array.getsize() - array.setdata([(size+1)/2] * size) + array.setdata([(size+1)//2] * size) array.reset("Uniform data, size %d" % size) def distinct(array): @@ -429,7 +429,7 @@ def quicksort(array): j = j-1 continue array.message("Choosing pivot") - j, i, k = first, (first+last)/2, last-1 + j, i, k = first, (first+last)//2, last-1 if array.compare(k, i) < 0: array.swap(k, i) if array.compare(k, j) < 0: |