diff --git a/pysollib/games/buffalobill.py b/pysollib/games/buffalobill.py index 726c8cd2..1630a8ed 100644 --- a/pysollib/games/buffalobill.py +++ b/pysollib/games/buffalobill.py @@ -56,7 +56,7 @@ class BuffaloBill(Game): self.setSize(w, h) # create stacks - x, y = l.XM+(w-l.XM-8*l.XS)/2, l.YM + x, y = l.XM+(w-l.XM-8*l.XS)//2, l.YM for i in range(4): s.foundations.append(SS_FoundationStack(x, y, self, suit=i)) x += l.XS @@ -76,7 +76,7 @@ class BuffaloBill(Game): n += 1 y += l.YS - x, y = l.XM+(w-l.XM-8*l.XS)/2, h-l.YS + x, y = l.XM+(w-l.XM-8*l.XS)//2, h-l.YS for i in range(8): s.reserves.append(ReserveStack(x, y, self)) x += l.XS diff --git a/pysollib/games/freecell.py b/pysollib/games/freecell.py index b9d77c57..c2086c71 100644 --- a/pysollib/games/freecell.py +++ b/pysollib/games/freecell.py @@ -258,16 +258,16 @@ class TripleFreecell(FreeCell): # create stacks s.talon = self.Talon_Class(l.XM, h-l.YS, self) - x, y = l.XM+(max_rows-decks*4)*l.XS/2, l.YM + x, y = l.XM+(max_rows-decks*4)*l.XS//2, l.YM for j in range(4): for i in range(decks): s.foundations.append(self.Foundation_Class(x, y, self, suit=j)) x += l.XS - x, y = l.XM+(max_rows-reserves)*l.XS/2, l.YM+l.YS + x, y = l.XM+(max_rows-reserves)*l.XS//2, l.YM+l.YS for i in range(reserves): s.reserves.append(ReserveStack(x, y, self)) x += l.XS - x, y = l.XM+(max_rows-rows)*l.XS/2, l.YM+2*l.YS + x, y = l.XM+(max_rows-rows)*l.XS//2, l.YM+2*l.YS for i in range(rows): s.rows.append(self.RowStack_Class(x, y, self)) x += l.XS @@ -573,7 +573,7 @@ class Headquarters(Game): l, s = Layout(self), self.s w, h = l.XM+(rows+reserves+1)*l.XS, l.YM+3*l.YS+16*l.YOFFSET self.setSize(w, h) - x, y = l.XM+(rows+reserves+1-8)*l.XS/2, l.YM + x, y = l.XM+(rows+reserves+1-8)*l.XS//2, l.YM for i in range(8): s.foundations.append(SS_FoundationStack(x, y, self, suit=i % 4)) x += l.XS diff --git a/pysollib/images.py b/pysollib/images.py index 954063e9..ce8f6f52 100644 --- a/pysollib/images.py +++ b/pysollib/images.py @@ -365,8 +365,8 @@ class Images: return r = self.reduced if r > 1: - self.CARD_XOFFSET = max(10/r, cs.CARD_XOFFSET) - self.CARD_YOFFSET = max(10/r, cs.CARD_YOFFSET) + self.CARD_XOFFSET = max(10//r, cs.CARD_XOFFSET) + self.CARD_YOFFSET = max(10//r, cs.CARD_YOFFSET) else: self.CARD_XOFFSET = cs.CARD_XOFFSET self.CARD_YOFFSET = cs.CARD_YOFFSET diff --git a/pysollib/pysolgtk/progressbar.py b/pysollib/pysolgtk/progressbar.py index 8d26273c..7d78f8b3 100644 --- a/pysollib/pysolgtk/progressbar.py +++ b/pysollib/pysolgtk/progressbar.py @@ -109,7 +109,7 @@ class PysolProgressBar: def update(self, percent=None, step=1): # self.steps_sum += step # print self.steps_sum, self.norm - step = step/self.norm + step /= self.norm if percent is None: self.percent += step elif percent > self.percent: diff --git a/pysollib/pysolgtk/selecttile.py b/pysollib/pysolgtk/selecttile.py index 27e94811..91632950 100644 --- a/pysollib/pysolgtk/selecttile.py +++ b/pysollib/pysolgtk/selecttile.py @@ -168,7 +168,7 @@ class SelectTileDialogWithPreview(MfxDialog): def _colorselOkClicked(self, w, d): c = d.colorsel.get_current_color() - c = '#%02x%02x%02x' % (c.red/256, c.green/256, c.blue/256) + c = '#%02x%02x%02x' % (c.red//256, c.green//256, c.blue//256) d.destroy() self.updatePreview(c) self.treeview.unselectAll() diff --git a/pysollib/pysolgtk/tkcanvas.py b/pysollib/pysolgtk/tkcanvas.py index 3205dc8f..cf0313a7 100644 --- a/pysollib/pysolgtk/tkcanvas.py +++ b/pysollib/pysolgtk/tkcanvas.py @@ -298,7 +298,7 @@ class MfxCanvas(gnomecanvas.Canvas): # gnomecanvas.Canvas.__init__(self) c = top.style.bg[gtk.STATE_NORMAL] - c = '#%02x%02x%02x' % (c.red/256, c.green/256, c.blue/256) + c = '#%02x%02x%02x' % (c.red//256, c.green//256, c.blue//256) self.top_bg = c if bg is not None: self.modify_bg(gtk.STATE_NORMAL, gdk.color_parse(bg)) @@ -520,7 +520,7 @@ class MfxCanvas(gnomecanvas.Canvas): pixbuf = image.pixbuf w, h = self.get_size() iw, ih = pixbuf.get_width(), pixbuf.get_height() - x, y = (w-iw)/2, (h-ih)/2 + x, y = (w-iw)//2, (h-ih)//2 dx, dy = self.world_to_window(0, 0) dx, dy = int(dx), int(dy) self.__topimage = self.root().add(gnomecanvas.CanvasPixbuf, diff --git a/pysollib/pysolgtk/tkstats.py b/pysollib/pysolgtk/tkstats.py index e58cd245..f74c3a6d 100644 --- a/pysollib/pysolgtk/tkstats.py +++ b/pysollib/pysolgtk/tkstats.py @@ -295,9 +295,9 @@ class Game_StatsDialog: width, height = alloc.width, alloc.height w, h = 90, 50 # x, y = 10, 10 - x, y = (width-w)/2, (height-h)/2 + x, y = (width-w)//2, (height-h)//2 dy = 9 - y = y-dy/2 + y -= dy//2 if won+lost > 0: gc.set_foreground(colormap.alloc_color('#008000')) @@ -328,8 +328,8 @@ class Game_StatsDialog: gc.set_foreground(colormap.alloc_color('#a0a0a0')) pangolayout = drawing.create_pango_layout(_('No games')) ext = pangolayout.get_extents() - tw, th = ext[1][2]/pango.SCALE, ext[1][3]/pango.SCALE - win.draw_layout(gc, x+w/2-tw/2, y+h/2-th/2, pangolayout) + tw, th = ext[1][2]//pango.SCALE, ext[1][3]//pango.SCALE + win.draw_layout(gc, x+w//2-tw//2, y+h//2-th//2, pangolayout) def _createTop(self): for n in ('top_10_time_treeview', diff --git a/pysollib/pysolgtk/tkwrap.py b/pysollib/pysolgtk/tkwrap.py index fb9825cf..61b022ad 100644 --- a/pysollib/pysolgtk/tkwrap.py +++ b/pysollib/pysolgtk/tkwrap.py @@ -72,7 +72,7 @@ class _MfxToplevel(gtk.Window): # return self.get_window().get_cursor(v) elif attr in ("background", "bg"): c = self.style.bg[gtk.STATE_NORMAL] - c = '#%02x%02x%02x' % (c.red/256, c.green/256, c.blue/256) + c = '#%02x%02x%02x' % (c.red//256, c.green//256, c.blue//256) return c print("Toplevel cget:", attr) # ~ raise AttributeError, attr diff --git a/pysollib/tile/tkstats.py b/pysollib/tile/tkstats.py index 1b17c3c8..d05b3b12 100644 --- a/pysollib/tile/tkstats.py +++ b/pysollib/tile/tkstats.py @@ -242,7 +242,7 @@ class SingleGameFrame(ttk.Frame): # x = tx[0] dy = int(self.dialog.font_metrics['ascent']) - 10 - dy = dy/2 + dy //= 2 c.create_text(x, ty[0]-dy, text=_("Won:"), anchor="nw", font=tfont, fill=fg) c.create_text(x, ty[1]-dy, text=_("Lost:"), @@ -299,7 +299,7 @@ class SingleGameFrame(ttk.Frame): else: c.create_oval(x0, y0+d, x0+w, y0+h+d, fill="#7f7f7f") c.create_oval(x0, y0, x0+w, y0+h, fill="#f0f0f0") - c.create_text(x0+w/2, y0+h/2, text=_("No games"), + c.create_text(x0+w//2, y0+h//2, text=_("No games"), anchor="center", font=tfont, fill="#bfbfbf") # self._createChartTexts(tx, ty, won, lost) @@ -960,8 +960,8 @@ class ProgressionFrame(ttk.Frame): tw = max(measure(_('Games/day')), measure(_('Games/week')), measure(_('% won'))) - self.left_margin = self.xmargin+tw/2 - self.right_margin = self.xmargin+tw/2 + self.left_margin = self.xmargin+tw//2 + self.right_margin = self.xmargin+tw//2 self.top_margin = 15+self.text_height self.bottom_margin = 15+self.text_height+10+self.text_height # @@ -1018,12 +1018,12 @@ class ProgressionFrame(ttk.Frame): graph_width = self.canvas_width-self.left_margin-self.right_margin graph_height = self.canvas_height-self.top_margin-self.bottom_margin - dx = (graph_width-2*self.graph_dx)/(len(result)-1) - graph_dx = (graph_width-(len(result)-1)*dx)/2 - dy = (graph_height-self.graph_dy)/5 + dx = (graph_width-2*self.graph_dx)//(len(result)-1) + graph_dx = (graph_width-(len(result)-1)*dx)//2 + dy = (graph_height-self.graph_dy)//5 x0, y0 = self.left_margin, self.canvas_height-self.bottom_margin x1, y1 = self.canvas_width-self.right_margin, self.top_margin - td = self.text_height/2 + td = self.text_height//2 # vertical scale x = x0+graph_dx @@ -1051,7 +1051,7 @@ class ProgressionFrame(ttk.Frame): # horizontal scale max_games = max([i[1] for i in result]) - games_delta = max_games/5+1 + games_delta = max_games//5+1 percent = 0 games = 0 for y in range(y0, y1, -dy): diff --git a/pysollib/tile/tktree.py b/pysollib/tile/tktree.py index 4dc35e34..c46e999b 100644 --- a/pysollib/tile/tktree.py +++ b/pysollib/tile/tktree.py @@ -63,7 +63,7 @@ class MfxTreeBaseNode: def draw(self, x, y, lastx=None, lasty=None): canvas, style = self.tree.canvas, self.tree.style topleftx = x + style.distx - toplefty = y - style.height / 2 # +++ + toplefty = y - style.height // 2 # +++ # draw the horizontal line if lastx is not None: canvas.create_line( @@ -175,8 +175,8 @@ class MfxTreeNode(MfxTreeBaseNode): # draw the vertical line if self.subnodes: style = self.tree.style - dy = (style.disty-style.width)/2 - y = y-style.disty/2-dy + dy = (style.disty-style.width)//2 + y = y-style.disty//2-dy self.tree.canvas.create_line(x, y, nx, ly, stipple=style.linestyle, fill=style.linecolor) @@ -187,10 +187,10 @@ class MfxTreeNode(MfxTreeBaseNode): lx, ly, nx, ny = MfxTreeBaseNode.draw(self, x, y, ilastx, ilasty) if self.expanded: style = self.tree.style - childx = nx + style.distx + style.width / 2 + childx = nx + style.distx + style.width // 2 childy = ny - clastx = nx + style.distx + style.width / 2 - clasty = ly + style.height / 2 + clastx = nx + style.distx + style.width // 2 + clasty = ly + style.height // 2 ny = self.drawChildren(childx, childy, clastx, clasty) return lx, ly, x, ny @@ -273,8 +273,8 @@ class MfxTreeInCanvas(MfxScrolledCanvas): # Account for initial offsets, see topleft[xy] in BaseNode.draw(). # We do this so that our bounding box always starts at (0,0) # and the yscrollincrement works nicely. - nx = nx - self.style.distx - ny = ny + self.style.height / 2 + nx -= self.style.distx + ny += self.style.height // 2 for node in self.rootnodes: # update tree node.tree = self diff --git a/pysollib/tile/tkwidget.py b/pysollib/tile/tkwidget.py index 2c287445..477f375e 100644 --- a/pysollib/tile/tkwidget.py +++ b/pysollib/tile/tkwidget.py @@ -708,7 +708,7 @@ class StackDesc: font = game.app.getFont('canvas_small') # print self.app.cardset.CARDW, self.app.images.CARDW cardw = game.app.images.getSize()[0] - x, y = stack.x+cardw/2, stack.y + x, y = stack.x+cardw//2, stack.y text = stack.getHelp()+'\n'+stack.getBaseCard() text = text.strip() if text: @@ -752,9 +752,9 @@ class MyPysolScale: else: self.resolution = 1 if 'from_' in kw: - kw['from_'] = kw['from_']/self.resolution + kw['from_'] //= self.resolution if 'to' in kw: - kw['to'] = kw['to']/self.resolution + kw['to'] //= self.resolution if 'variable' in kw: self.variable = kw['variable'] del kw['variable']