mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
flake8
This commit is contained in:
parent
db66722d35
commit
e3c557b1d0
2 changed files with 251 additions and 215 deletions
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- mode: python; coding: utf-8; -*-
|
# -*- mode: python; coding: utf-8; -*-
|
||||||
# ---------------------------------------------------------------------------##
|
# ---------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer
|
# Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer
|
||||||
# Copyright (C) 2003 Mt. Hood Playing Card Co.
|
# Copyright (C) 2003 Mt. Hood Playing Card Co.
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
# ---------------------------------------------------------------------------##
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
__all__ = ['SingleGame_StatsDialog',
|
__all__ = ['SingleGame_StatsDialog',
|
||||||
'AllGames_StatsDialog',
|
'AllGames_StatsDialog',
|
||||||
|
@ -33,18 +33,19 @@ __all__ = ['SingleGame_StatsDialog',
|
||||||
# imports
|
# imports
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import Tkinter, tkFont
|
import Tkinter
|
||||||
|
import tkFont
|
||||||
|
|
||||||
# PySol imports
|
# PySol imports
|
||||||
from pysollib.mygettext import _, n_
|
from pysollib.mygettext import _
|
||||||
from pysollib.mfxutil import kwdefault, KwStruct
|
from pysollib.mfxutil import kwdefault, KwStruct
|
||||||
from pysollib.mfxutil import format_time
|
from pysollib.mfxutil import format_time
|
||||||
##from pysollib.util import *
|
# from pysollib.util import *
|
||||||
from pysollib.stats import PysolStatsFormatter, ProgressionFormatter
|
from pysollib.stats import PysolStatsFormatter, ProgressionFormatter
|
||||||
from pysollib.settings import TOP_TITLE
|
from pysollib.settings import TOP_TITLE
|
||||||
|
|
||||||
# Toolkit imports
|
# Toolkit imports
|
||||||
from pysollib.ui.tktile.tkutil import bind, unbind_destroy, loadImage
|
from pysollib.ui.tktile.tkutil import bind, loadImage
|
||||||
from tkwidget import MfxDialog, MfxMessageDialog
|
from tkwidget import MfxDialog, MfxMessageDialog
|
||||||
from tkwidget import MfxScrolledCanvas
|
from tkwidget import MfxScrolledCanvas
|
||||||
|
|
||||||
|
@ -69,12 +70,13 @@ class SingleGame_StatsDialog(MfxDialog):
|
||||||
self.top.wm_minsize(200, 200)
|
self.top.wm_minsize(200, 200)
|
||||||
self.button = kw.default
|
self.button = kw.default
|
||||||
#
|
#
|
||||||
##createChart = self.create3DBarChart
|
# createChart = self.create3DBarChart
|
||||||
createChart = self.createPieChart
|
createChart = self.createPieChart
|
||||||
##createChart = self.createSimpleChart
|
# createChart = self.createSimpleChart
|
||||||
## if parent.winfo_screenwidth() < 800 or parent.winfo_screenheight() < 600:
|
# if parent.winfo_screenwidth() < 800 or parent.winfo_screenheight() <
|
||||||
## createChart = self.createPieChart
|
# 600:
|
||||||
## createChart = self.createSimpleChart
|
# createChart = self.createPieChart
|
||||||
|
# createChart = self.createSimpleChart
|
||||||
#
|
#
|
||||||
self.font = self.app.getFont("default")
|
self.font = self.app.getFont("default")
|
||||||
self.tk_font = tkFont.Font(self.top, self.font)
|
self.tk_font = tkFont.Font(self.top, self.font)
|
||||||
|
@ -104,13 +106,13 @@ class SingleGame_StatsDialog(MfxDialog):
|
||||||
if len(i) > len(t):
|
if len(i) > len(t):
|
||||||
t = i
|
t = i
|
||||||
t1 = font.measure(t)
|
t1 = font.measure(t)
|
||||||
## t1 = max(font.measure(_("Won:")),
|
# t1 = max(font.measure(_("Won:")),
|
||||||
## font.measure(_("Lost:")),
|
# font.measure(_("Lost:")),
|
||||||
## font.measure(_("Total:")))
|
# font.measure(_("Total:")))
|
||||||
t1 += 10
|
t1 += 10
|
||||||
##t2 = font.measure('99999')+10
|
# t2 = font.measure('99999')+10
|
||||||
t2 = 45
|
t2 = 45
|
||||||
##t3 = font.measure('100%')+10
|
# t3 = font.measure('100%')+10
|
||||||
t3 = 45
|
t3 = 45
|
||||||
tx = (t0, t0+t1+t2, t0+t1+t2+t3)
|
tx = (t0, t0+t1+t2, t0+t1+t2+t3)
|
||||||
#
|
#
|
||||||
|
@ -134,7 +136,7 @@ class SingleGame_StatsDialog(MfxDialog):
|
||||||
c = Tkinter.Canvas(self.top_frame, width=w, height=h)
|
c = Tkinter.Canvas(self.top_frame, width=w, height=h)
|
||||||
c.pack(side='top', fill='both', expand=False, padx=20, pady=10)
|
c.pack(side='top', fill='both', expand=False, padx=20, pady=10)
|
||||||
self.canvas = c
|
self.canvas = c
|
||||||
##self.fg = c.cget("insertbackground")
|
# self.fg = c.cget("insertbackground")
|
||||||
self.fg = c.option_get('foreground', '') or c.cget("insertbackground")
|
self.fg = c.option_get('foreground', '') or c.cget("insertbackground")
|
||||||
#
|
#
|
||||||
c.create_rectangle(2, 7, w, h, fill="", outline="#7f7f7f")
|
c.create_rectangle(2, 7, w, h, fill="", outline="#7f7f7f")
|
||||||
|
@ -150,114 +152,131 @@ class SingleGame_StatsDialog(MfxDialog):
|
||||||
x = tx[0]
|
x = tx[0]
|
||||||
dy = int(self.font_metrics['ascent']) - 10
|
dy = int(self.font_metrics['ascent']) - 10
|
||||||
dy = dy/2
|
dy = dy/2
|
||||||
c.create_text(x, ty[0]-dy, text=_("Won:"), anchor="nw", font=tfont, fill=fg)
|
c.create_text(
|
||||||
c.create_text(x, ty[1]-dy, text=_("Lost:"), anchor="nw", font=tfont, fill=fg)
|
x, ty[0]-dy, text=_("Won:"), anchor="nw", font=tfont, fill=fg)
|
||||||
c.create_text(x, ty[2]-dy, text=_("Total:"), anchor="nw", font=tfont, fill=fg)
|
c.create_text(
|
||||||
|
x, ty[1]-dy, text=_("Lost:"), anchor="nw", font=tfont, fill=fg)
|
||||||
|
c.create_text(
|
||||||
|
x, ty[2]-dy, text=_("Total:"), anchor="nw", font=tfont, fill=fg)
|
||||||
x = tx[1] - 16
|
x = tx[1] - 16
|
||||||
c.create_text(x, ty[0]-dy, text="%d" % won, anchor="ne", font=tfont, fill=fg)
|
c.create_text(
|
||||||
c.create_text(x, ty[1]-dy, text="%d" % lost, anchor="ne", font=tfont, fill=fg)
|
x, ty[0]-dy, text="%d" % won, anchor="ne", font=tfont, fill=fg)
|
||||||
c.create_text(x, ty[2]-dy, text="%d" % (won + lost), anchor="ne", font=tfont, fill=fg)
|
c.create_text(
|
||||||
|
x, ty[1]-dy, text="%d" % lost, anchor="ne", font=tfont, fill=fg)
|
||||||
|
c.create_text(
|
||||||
|
x, ty[2]-dy, text="%d" % (won + lost), anchor="ne", font=tfont,
|
||||||
|
fill=fg)
|
||||||
y = ty[2] - 11
|
y = ty[2] - 11
|
||||||
c.create_line(tx[0], y, x, y, fill=fg)
|
c.create_line(tx[0], y, x, y, fill=fg)
|
||||||
if won + lost > 0:
|
if won + lost > 0:
|
||||||
x = tx[2]
|
x = tx[2]
|
||||||
pw = int(round(100.0 * pwon))
|
pw = int(round(100.0 * pwon))
|
||||||
c.create_text(x, ty[0]-dy, text="%d%%" % pw, anchor="ne", font=tfont, fill=fg)
|
c.create_text(
|
||||||
c.create_text(x, ty[1]-dy, text="%d%%" % (100-pw), anchor="ne", font=tfont, fill=fg)
|
x, ty[0]-dy, text="%d%%" % pw, anchor="ne",
|
||||||
|
font=tfont, fill=fg)
|
||||||
|
c.create_text(
|
||||||
|
x, ty[1]-dy, text="%d%%" % (100-pw), anchor="ne", font=tfont,
|
||||||
|
fill=fg)
|
||||||
|
|
||||||
|
|
||||||
## def _createChart3DBar(self, canvas, perc, x, y, p, col):
|
# def _createChart3DBar(self, canvas, perc, x, y, p, col):
|
||||||
## if perc < 0.005:
|
# if perc < 0.005:
|
||||||
## return
|
# return
|
||||||
## # translate and scale
|
# # translate and scale
|
||||||
## p = list(p[:])
|
# p = list(p[:])
|
||||||
## for i in (0, 1, 2, 3):
|
# for i in (0, 1, 2, 3):
|
||||||
## p[i] = (x + p[i][0], y + p[i][1])
|
# p[i] = (x + p[i][0], y + p[i][1])
|
||||||
## j = i + 4
|
# j = i + 4
|
||||||
## dx = int(round(p[j][0] * perc))
|
# dx = int(round(p[j][0] * perc))
|
||||||
## dy = int(round(p[j][1] * perc))
|
# dy = int(round(p[j][1] * perc))
|
||||||
## p[j] = (p[i][0] + dx, p[i][1] + dy)
|
# p[j] = (p[i][0] + dx, p[i][1] + dy)
|
||||||
## # draw rects
|
# # draw rects
|
||||||
## def draw_rect(a, b, c, d, col, canvas=canvas, p=p):
|
# def draw_rect(a, b, c, d, col, canvas=canvas, p=p):
|
||||||
## points = (p[a][0], p[a][1], p[b][0], p[b][1],
|
# points = (p[a][0], p[a][1], p[b][0], p[b][1],
|
||||||
## p[c][0], p[c][1], p[d][0], p[d][1])
|
# p[c][0], p[c][1], p[d][0], p[d][1])
|
||||||
## canvas.create_polygon(points, fill=col)
|
# canvas.create_polygon(points, fill=col)
|
||||||
## draw_rect(0, 1, 5, 4, col[0])
|
# draw_rect(0, 1, 5, 4, col[0])
|
||||||
## draw_rect(1, 2, 6, 5, col[1])
|
# draw_rect(1, 2, 6, 5, col[1])
|
||||||
## draw_rect(4, 5, 6, 7, col[2])
|
# draw_rect(4, 5, 6, 7, col[2])
|
||||||
## # draw lines
|
# # draw lines
|
||||||
## def draw_line(a, b, canvas=canvas, p=p):
|
# def draw_line(a, b, canvas=canvas, p=p):
|
||||||
## ##print a, b, p[a], p[b]
|
# # print a, b, p[a], p[b]
|
||||||
## canvas.create_line(p[a][0], p[a][1], p[b][0], p[b][1])
|
# canvas.create_line(p[a][0], p[a][1], p[b][0], p[b][1])
|
||||||
## draw_line(0, 1)
|
# draw_line(0, 1)
|
||||||
## draw_line(1, 2)
|
# draw_line(1, 2)
|
||||||
## draw_line(0, 4)
|
# draw_line(0, 4)
|
||||||
## draw_line(1, 5)
|
# draw_line(1, 5)
|
||||||
## draw_line(2, 6)
|
# draw_line(2, 6)
|
||||||
## ###draw_line(3, 7) ## test
|
# # draw_line(3, 7) # test
|
||||||
## draw_line(4, 5)
|
# draw_line(4, 5)
|
||||||
## draw_line(5, 6)
|
# draw_line(5, 6)
|
||||||
## draw_line(6, 7)
|
# draw_line(6, 7)
|
||||||
## draw_line(7, 4)
|
# draw_line(7, 4)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# charts
|
# charts
|
||||||
#
|
#
|
||||||
|
|
||||||
## def createSimpleChart(self, app, won, lost, text):
|
# def createSimpleChart(self, app, won, lost, text):
|
||||||
## #c, tfont, fg = self._createChartInit(frame, 300, 100, text)
|
# #c, tfont, fg = self._createChartInit(frame, 300, 100, text)
|
||||||
## self._createChartInit(300, 100, text)
|
# self._createChartInit(300, 100, text)
|
||||||
## c, tfont, fg = self.canvas, self.font, self.fg
|
# c, tfont, fg = self.canvas, self.font, self.fg
|
||||||
## #
|
# #
|
||||||
## tx = (90, 180, 210)
|
# tx = (90, 180, 210)
|
||||||
## ty = (21, 41, 75)
|
# ty = (21, 41, 75)
|
||||||
## self._createChartTexts(tx, ty, won, lost)
|
# self._createChartTexts(tx, ty, won, lost)
|
||||||
|
|
||||||
## def create3DBarChart(self, app, won, lost, text):
|
# def create3DBarChart(self, app, won, lost, text):
|
||||||
## image = app.gimages.stats[0]
|
# image = app.gimages.stats[0]
|
||||||
## iw, ih = image.width(), image.height()
|
# iw, ih = image.width(), image.height()
|
||||||
## #c, tfont, fg = self._createChartInit(frame, iw+160, ih, text)
|
# #c, tfont, fg = self._createChartInit(frame, iw+160, ih, text)
|
||||||
## self._createChartInit(iw+160, ih, text)
|
# self._createChartInit(iw+160, ih, text)
|
||||||
## c, tfont, fg = self.canvas, self.font, self.fg
|
# c, tfont, fg = self.canvas, self.font, self.fg
|
||||||
## pwon, plost = self._getPwon(won, lost)
|
# pwon, plost = self._getPwon(won, lost)
|
||||||
## #
|
# #
|
||||||
## tx = (iw+20, iw+110, iw+140)
|
# tx = (iw+20, iw+110, iw+140)
|
||||||
## yy = ih/2 ## + 7
|
# yy = ih/2 # + 7
|
||||||
## ty = (yy+21-46, yy+41-46, yy+75-46)
|
# ty = (yy+21-46, yy+41-46, yy+75-46)
|
||||||
## #
|
# #
|
||||||
## c.create_image(0, 7, image=image, anchor="nw")
|
# c.create_image(0, 7, image=image, anchor="nw")
|
||||||
## #
|
# #
|
||||||
## p = ((0, 0), (44, 6), (62, -9), (20, -14),
|
# p = ((0, 0), (44, 6), (62, -9), (20, -14),
|
||||||
## (-3, -118), (-1, -120), (-1, -114), (-4, -112))
|
# (-3, -118), (-1, -120), (-1, -114), (-4, -112))
|
||||||
## col = ("#00ff00", "#008200", "#00c300")
|
# col = ("#00ff00", "#008200", "#00c300")
|
||||||
## self._createChart3DBar(c, pwon, 102, 145+7, p, col)
|
# self._createChart3DBar(c, pwon, 102, 145+7, p, col)
|
||||||
## p = ((0, 0), (49, 6), (61, -10), (15, -15),
|
# p = ((0, 0), (49, 6), (61, -10), (15, -15),
|
||||||
## (1, -123), (3, -126), (4, -120), (1, -118))
|
# (1, -123), (3, -126), (4, -120), (1, -118))
|
||||||
## col = ("#ff0000", "#860400", "#c70400")
|
# col = ("#ff0000", "#860400", "#c70400")
|
||||||
## self._createChart3DBar(c, plost, 216, 159+7, p, col)
|
# self._createChart3DBar(c, plost, 216, 159+7, p, col)
|
||||||
## #
|
# #
|
||||||
## self._createChartTexts(tx, ty, won, lost)
|
# self._createChartTexts(tx, ty, won, lost)
|
||||||
## c.create_text(tx[0], ty[0]-48, text=self.player, anchor="nw", font=tfont, fill=fg)
|
# c.create_text(tx[0], ty[0]-48, text=self.player, anchor="nw",
|
||||||
|
# font=tfont, fill=fg)
|
||||||
|
|
||||||
def createPieChart(self, app, won, lost, text):
|
def createPieChart(self, app, won, lost, text):
|
||||||
#c, tfont, fg = self._createChartInit(frame, 300, 100, text)
|
# c, tfont, fg = self._createChartInit(frame, 300, 100, text)
|
||||||
#
|
#
|
||||||
self._createChartInit(text)
|
self._createChartInit(text)
|
||||||
c, tfont, fg = self.canvas, self.font, self.fg
|
c, tfont = self.canvas, self.font
|
||||||
pwon, plost = self._getPwon(won, lost)
|
pwon, plost = self._getPwon(won, lost)
|
||||||
#
|
#
|
||||||
#tx = (160, 250, 280)
|
# tx = (160, 250, 280)
|
||||||
#ty = (21, 41, 75)
|
# ty = (21, 41, 75)
|
||||||
#
|
#
|
||||||
tx, ty = self.tab_x, self.tab_y
|
tx, ty = self.tab_x, self.tab_y
|
||||||
if won + lost > 0:
|
if won + lost > 0:
|
||||||
##s, ewon, elost = 90.0, -360.0 * pwon, -360.0 * plost
|
# s, ewon, elost = 90.0, -360.0 * pwon, -360.0 * plost
|
||||||
s, ewon, elost = 0.0, 360.0 * pwon, 360.0 * plost
|
s, ewon, elost = 0.0, 360.0 * pwon, 360.0 * plost
|
||||||
c.create_arc(20, 25+9, 110, 75+9, fill="#007f00", start=s, extent=ewon)
|
c.create_arc(
|
||||||
c.create_arc(20, 25+9, 110, 75+9, fill="#7f0000", start=s+ewon, extent=elost)
|
20, 25+9, 110, 75+9, fill="#007f00", start=s, extent=ewon)
|
||||||
c.create_arc(20, 25, 110, 75, fill="#00ff00", start=s, extent=ewon)
|
c.create_arc(
|
||||||
c.create_arc(20, 25, 110, 75, fill="#ff0000", start=s+ewon, extent=elost)
|
20, 25+9, 110, 75+9, fill="#7f0000", start=s+ewon,
|
||||||
|
extent=elost)
|
||||||
|
c.create_arc(
|
||||||
|
20, 25, 110, 75, fill="#00ff00", start=s, extent=ewon)
|
||||||
|
c.create_arc(
|
||||||
|
20, 25, 110, 75, fill="#ff0000", start=s+ewon,
|
||||||
|
extent=elost)
|
||||||
x, y = tx[0] - 25, ty[0]
|
x, y = tx[0] - 25, ty[0]
|
||||||
c.create_rectangle(x, y, x+10, y+10, fill="#00ff00")
|
c.create_rectangle(x, y, x+10, y+10, fill="#00ff00")
|
||||||
y = ty[1]
|
y = ty[1]
|
||||||
|
@ -265,7 +284,9 @@ class SingleGame_StatsDialog(MfxDialog):
|
||||||
else:
|
else:
|
||||||
c.create_oval(20, 25+10, 110, 75+10, fill="#7f7f7f")
|
c.create_oval(20, 25+10, 110, 75+10, fill="#7f7f7f")
|
||||||
c.create_oval(20, 25, 110, 75, fill="#f0f0f0")
|
c.create_oval(20, 25, 110, 75, fill="#f0f0f0")
|
||||||
c.create_text(65, 50, text=_("No games"), anchor="center", font=tfont, fill="#bfbfbf")
|
c.create_text(
|
||||||
|
65, 50, text=_("No games"), anchor="center",
|
||||||
|
font=tfont, fill="#bfbfbf")
|
||||||
#
|
#
|
||||||
self._createChartTexts(tx, ty, won, lost)
|
self._createChartTexts(tx, ty, won, lost)
|
||||||
|
|
||||||
|
@ -274,13 +295,14 @@ class SingleGame_StatsDialog(MfxDialog):
|
||||||
#
|
#
|
||||||
|
|
||||||
def initKw(self, kw):
|
def initKw(self, kw):
|
||||||
kw = KwStruct(kw,
|
kw = KwStruct(
|
||||||
strings=(_("&OK"),
|
kw,
|
||||||
(_("&All games..."), 102),
|
strings=(_("&OK"),
|
||||||
(TOP_TITLE+"...", 105),
|
(_("&All games..."), 102),
|
||||||
(_("&Reset..."), 302)), default=0,
|
(TOP_TITLE+"...", 105),
|
||||||
image=self.app.gimages.logos[5],
|
(_("&Reset..."), 302)), default=0,
|
||||||
padx=10, pady=10,
|
image=self.app.gimages.logos[5],
|
||||||
|
padx=10, pady=10,
|
||||||
)
|
)
|
||||||
return MfxDialog.initKw(self, kw)
|
return MfxDialog.initKw(self, kw)
|
||||||
|
|
||||||
|
@ -294,12 +316,13 @@ class CanvasFormatter(PysolStatsFormatter):
|
||||||
self.app = app
|
self.app = app
|
||||||
self.canvas = canvas
|
self.canvas = canvas
|
||||||
self.parent_window = parent_window
|
self.parent_window = parent_window
|
||||||
##self.fg = canvas.cget("insertbackground")
|
# self.fg = canvas.cget("insertbackground")
|
||||||
self.fg = canvas.option_get('foreground', '') or canvas.cget("insertbackground")
|
self.fg = canvas.option_get('foreground', '') or \
|
||||||
|
canvas.cget("insertbackground")
|
||||||
self.font = font
|
self.font = font
|
||||||
self.w = w
|
self.w = w
|
||||||
self.h = h
|
self.h = h
|
||||||
#self.x = self.y = 0
|
# self.x = self.y = 0
|
||||||
self.gameid = None
|
self.gameid = None
|
||||||
self.gamenumber = None
|
self.gamenumber = None
|
||||||
self.canvas.config(yscrollincrement=h)
|
self.canvas.config(yscrollincrement=h)
|
||||||
|
@ -310,7 +333,7 @@ class CanvasFormatter(PysolStatsFormatter):
|
||||||
|
|
||||||
def _calc_tabs(self, arg):
|
def _calc_tabs(self, arg):
|
||||||
tw = 15*self.w
|
tw = 15*self.w
|
||||||
##tw = 160
|
# tw = 160
|
||||||
self._tabs = [tw]
|
self._tabs = [tw]
|
||||||
font = tkFont.Font(self.canvas, self.font)
|
font = tkFont.Font(self.canvas, self.font)
|
||||||
for t in arg[1:]:
|
for t in arg[1:]:
|
||||||
|
@ -331,10 +354,11 @@ class CanvasFormatter(PysolStatsFormatter):
|
||||||
('lost', t4, 'ne', self._tabs[4]),
|
('lost', t4, 'ne', self._tabs[4]),
|
||||||
('time', t5, 'ne', self._tabs[5]),
|
('time', t5, 'ne', self._tabs[5]),
|
||||||
('moves', t6, 'ne', self._tabs[6]),
|
('moves', t6, 'ne', self._tabs[6]),
|
||||||
('percent', t7, 'ne', self._tabs[7]), ):
|
('percent', t7, 'ne', self._tabs[7]),
|
||||||
|
):
|
||||||
self.gamenumber = None
|
self.gamenumber = None
|
||||||
if gameid is None: # header
|
if gameid is None: # header
|
||||||
self.gamenumber=var
|
self.gamenumber = var
|
||||||
id = self.canvas.create_text(x, y, text=text, anchor=anchor,
|
id = self.canvas.create_text(x, y, text=text, anchor=anchor,
|
||||||
font=self.font, fill=self.fg)
|
font=self.font, fill=self.fg)
|
||||||
self._addItem(id)
|
self._addItem(id)
|
||||||
|
@ -355,38 +379,41 @@ class CanvasFormatter(PysolStatsFormatter):
|
||||||
if w > 0:
|
if w > 0:
|
||||||
w = max(3, w)
|
w = max(3, w)
|
||||||
w = min(rw - 2, w)
|
w = min(rw - 2, w)
|
||||||
id = self.canvas.create_rectangle(rx, ry, rx+w, ry+rh, width=1,
|
self.canvas.create_rectangle(
|
||||||
fill="#00ff00", outline="#000000")
|
rx, ry, rx+w, ry+rh, width=1,
|
||||||
|
fill="#00ff00", outline="#000000")
|
||||||
if w < rw:
|
if w < rw:
|
||||||
id = self.canvas.create_rectangle(rx+w, ry, rx+rw, ry+rh, width=1,
|
self.canvas.create_rectangle(
|
||||||
fill="#ff0000", outline="#000000")
|
rx+w, ry, rx+rw, ry+rh, width=1,
|
||||||
|
fill="#ff0000", outline="#000000")
|
||||||
return
|
return
|
||||||
##fill = "#ffffff"
|
# fill = "#ffffff"
|
||||||
##fill = self.canvas["bg"]
|
# fill = self.canvas["bg"]
|
||||||
fill = None
|
fill = None
|
||||||
id = self.canvas.create_rectangle(rx, ry, rx+rw, ry+rh, width=1,
|
self.canvas.create_rectangle(rx, ry, rx+rw, ry+rh, width=1,
|
||||||
fill=fill, outline="#808080")
|
fill=fill, outline="#808080")
|
||||||
if 1:
|
if 1:
|
||||||
rx, rw = rx + 1, rw - 1
|
rx, rw = rx + 1, rw - 1
|
||||||
ry, rh = ry + 1, rh - 1
|
ry, rh = ry + 1, rh - 1
|
||||||
w = int(round(rw*perc/100.0))
|
w = int(round(rw*perc/100.0))
|
||||||
if w > 0:
|
if w > 0:
|
||||||
id = self.canvas.create_rectangle(rx, ry, rx+w, ry+rh, width=0,
|
self.canvas.create_rectangle(rx, ry, rx+w, ry+rh, width=0,
|
||||||
fill="#00ff00", outline="")
|
fill="#00ff00", outline="")
|
||||||
if w < rw:
|
if w < rw:
|
||||||
id = self.canvas.create_rectangle(rx+w, ry, rx+rw, ry+rh, width=0,
|
self.canvas.create_rectangle(
|
||||||
fill="#ff0000", outline="")
|
rx+w, ry, rx+rw, ry+rh, width=0,
|
||||||
|
fill="#ff0000", outline="")
|
||||||
return
|
return
|
||||||
p = 1.0
|
p = 1.0
|
||||||
ix = rx + 2
|
ix = rx + 2
|
||||||
for i in (1, 11, 21, 31, 41, 51, 61, 71, 81, 91):
|
for i in (1, 11, 21, 31, 41, 51, 61, 71, 81, 91):
|
||||||
if perc < i:
|
if perc < i:
|
||||||
break
|
break
|
||||||
##c = "#ff8040"
|
# c = "#ff8040"
|
||||||
r, g, b = 255, 128*p, 64*p
|
r, g, b = 255, 128*p, 64*p
|
||||||
c = "#%02x%02x%02x" % (int(r), int(g), int(b))
|
c = "#%02x%02x%02x" % (int(r), int(g), int(b))
|
||||||
id = self.canvas.create_rectangle(ix, ry+2, ix+6, ry+rh-2, width=0,
|
self.canvas.create_rectangle(ix, ry+2, ix+6, ry+rh-2, width=0,
|
||||||
fill=c, outline=c)
|
fill=c, outline=c)
|
||||||
ix = ix + 8
|
ix = ix + 8
|
||||||
p = max(0.0, p - 0.1)
|
p = max(0.0, p - 0.1)
|
||||||
|
|
||||||
|
@ -450,7 +477,7 @@ class AllGames_StatsDialog(MfxDialog):
|
||||||
|
|
||||||
def __init__(self, parent, title, app, player, **kw):
|
def __init__(self, parent, title, app, player, **kw):
|
||||||
lines = 25
|
lines = 25
|
||||||
#if parent and parent.winfo_screenheight() < 600:
|
# if parent and parent.winfo_screenheight() < 600:
|
||||||
# lines = 20
|
# lines = 20
|
||||||
#
|
#
|
||||||
self.font = app.getFont(self.FONT_TYPE)
|
self.font = app.getFont(self.FONT_TYPE)
|
||||||
|
@ -474,8 +501,8 @@ class AllGames_StatsDialog(MfxDialog):
|
||||||
self.top.wm_minsize(200, 200)
|
self.top.wm_minsize(200, 200)
|
||||||
self.button = kw.default
|
self.button = kw.default
|
||||||
#
|
#
|
||||||
self.sc = AllGames_StatsDialogScrolledCanvas(top_frame,
|
self.sc = AllGames_StatsDialogScrolledCanvas(
|
||||||
width=kw.width, height=kw.height)
|
top_frame, width=kw.width, height=kw.height)
|
||||||
self.sc.pack(fill='both', expand=True, padx=kw.padx, pady=kw.pady)
|
self.sc.pack(fill='both', expand=True, padx=kw.padx, pady=kw.pady)
|
||||||
#
|
#
|
||||||
self.nodes = {}
|
self.nodes = {}
|
||||||
|
@ -484,10 +511,10 @@ class AllGames_StatsDialog(MfxDialog):
|
||||||
bind(self.canvas, "<1>", self.singleClick)
|
bind(self.canvas, "<1>", self.singleClick)
|
||||||
self.fillCanvas(player, title)
|
self.fillCanvas(player, title)
|
||||||
bbox = self.canvas.bbox("all")
|
bbox = self.canvas.bbox("all")
|
||||||
##print bbox
|
# print bbox
|
||||||
##self.canvas.config(scrollregion=bbox)
|
# self.canvas.config(scrollregion=bbox)
|
||||||
dx, dy = 4, 0
|
dx, dy = 4, 0
|
||||||
self.canvas.config(scrollregion=(-dx,-dy,bbox[2]+dx,bbox[3]+dy))
|
self.canvas.config(scrollregion=(-dx, -dy, bbox[2]+dx, bbox[3]+dy))
|
||||||
self.canvas.xview_moveto(-dx)
|
self.canvas.xview_moveto(-dx)
|
||||||
self.canvas.yview_moveto(self.YVIEW)
|
self.canvas.yview_moveto(self.YVIEW)
|
||||||
#
|
#
|
||||||
|
@ -495,14 +522,15 @@ class AllGames_StatsDialog(MfxDialog):
|
||||||
self.mainloop(focus, kw.timeout)
|
self.mainloop(focus, kw.timeout)
|
||||||
|
|
||||||
def initKw(self, kw):
|
def initKw(self, kw):
|
||||||
kw = KwStruct(kw,
|
kw = KwStruct(
|
||||||
strings=(_("&OK"),
|
kw,
|
||||||
(_("&Save to file"), 202),
|
strings=(_("&OK"),
|
||||||
(_("&Reset all..."), 301),),
|
(_("&Save to file"), 202),
|
||||||
default=0,
|
(_("&Reset all..."), 301),),
|
||||||
resizable=True,
|
default=0,
|
||||||
padx=10, pady=10,
|
resizable=True,
|
||||||
#width=900,
|
padx=10, pady=10,
|
||||||
|
# width=900,
|
||||||
)
|
)
|
||||||
return MfxDialog.initKw(self, kw)
|
return MfxDialog.initKw(self, kw)
|
||||||
|
|
||||||
|
@ -514,7 +542,8 @@ class AllGames_StatsDialog(MfxDialog):
|
||||||
MfxDialog.destroy(self)
|
MfxDialog.destroy(self)
|
||||||
|
|
||||||
def rearrange(self, sort_by):
|
def rearrange(self, sort_by):
|
||||||
if self.sort_by == sort_by: return
|
if self.sort_by == sort_by:
|
||||||
|
return
|
||||||
self.sort_by = sort_by
|
self.sort_by = sort_by
|
||||||
self.fillCanvas(self.player, self.title)
|
self.fillCanvas(self.player, self.title)
|
||||||
|
|
||||||
|
@ -522,19 +551,20 @@ class AllGames_StatsDialog(MfxDialog):
|
||||||
id = self.canvas.find_withtag('current')
|
id = self.canvas.find_withtag('current')
|
||||||
if not id:
|
if not id:
|
||||||
return
|
return
|
||||||
##print 'singleClick:', id, self.nodes.get(id[0])
|
# print 'singleClick:', id, self.nodes.get(id[0])
|
||||||
gameid, gamenumber = self.nodes.get(id[0], (None, None))
|
gameid, gamenumber = self.nodes.get(id[0], (None, None))
|
||||||
if gameid == 'header':
|
if gameid == 'header':
|
||||||
if self.sort_by == gamenumber: return
|
if self.sort_by == gamenumber:
|
||||||
|
return
|
||||||
self.sort_by = gamenumber
|
self.sort_by = gamenumber
|
||||||
self.fillCanvas(self.player, self.title)
|
self.fillCanvas(self.player, self.title)
|
||||||
return
|
return
|
||||||
## FIXME / TODO
|
# FIXME / TODO
|
||||||
return
|
return
|
||||||
if gameid and gamenumber:
|
if gameid and gamenumber:
|
||||||
print gameid, gamenumber
|
print(gameid, gamenumber)
|
||||||
elif gameid:
|
elif gameid:
|
||||||
print gameid
|
print(gameid)
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
@ -544,7 +574,7 @@ class AllGames_StatsDialog(MfxDialog):
|
||||||
self.canvas.delete('all')
|
self.canvas.delete('all')
|
||||||
self.nodes = {}
|
self.nodes = {}
|
||||||
writer = CanvasFormatter(self.app, self.canvas, self,
|
writer = CanvasFormatter(self.app, self.canvas, self,
|
||||||
self.font, self.CHAR_W, self.CHAR_H)
|
self.font, self.CHAR_W, self.CHAR_H)
|
||||||
writer.writeStats(player, self.sort_by)
|
writer.writeStats(player, self.sort_by)
|
||||||
|
|
||||||
|
|
||||||
|
@ -563,7 +593,8 @@ class FullLog_StatsDialog(AllGames_StatsDialog):
|
||||||
|
|
||||||
def initKw(self, kw):
|
def initKw(self, kw):
|
||||||
kw = KwStruct(kw,
|
kw = KwStruct(kw,
|
||||||
strings=(_("&OK"), (_("Session &log..."), 104), (_("&Save to file"), 203)), default=0,
|
strings=(_("&OK"), (_("Session &log..."), 104),
|
||||||
|
(_("&Save to file"), 203)), default=0,
|
||||||
width=76*self.CHAR_W,
|
width=76*self.CHAR_W,
|
||||||
)
|
)
|
||||||
return AllGames_StatsDialog.initKw(self, kw)
|
return AllGames_StatsDialog.initKw(self, kw)
|
||||||
|
@ -571,21 +602,24 @@ class FullLog_StatsDialog(AllGames_StatsDialog):
|
||||||
|
|
||||||
class SessionLog_StatsDialog(FullLog_StatsDialog):
|
class SessionLog_StatsDialog(FullLog_StatsDialog):
|
||||||
def fillCanvas(self, player, header):
|
def fillCanvas(self, player, header):
|
||||||
a = PysolStatsFormatter()
|
PysolStatsFormatter()
|
||||||
writer = CanvasFormatter(self.app, self.canvas, self,
|
writer = CanvasFormatter(self.app, self.canvas, self,
|
||||||
self.font, self.CHAR_W, self.CHAR_H)
|
self.font, self.CHAR_W, self.CHAR_H)
|
||||||
writer.writeSessionLog(player)
|
writer.writeSessionLog(player)
|
||||||
|
|
||||||
def initKw(self, kw):
|
def initKw(self, kw):
|
||||||
kw = KwStruct(kw,
|
kw = KwStruct(
|
||||||
strings=(_("&OK"), (_("&Full log..."), 103), (_("&Save to file"), 204)), default=0,
|
kw,
|
||||||
)
|
strings=(_("&OK"), (_("&Full log..."), 103),
|
||||||
|
(_("&Save to file"), 204)),
|
||||||
|
default=0,)
|
||||||
return FullLog_StatsDialog.initKw(self, kw)
|
return FullLog_StatsDialog.initKw(self, kw)
|
||||||
|
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
# *
|
# *
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
|
|
||||||
|
|
||||||
class Status_StatsDialog(MfxMessageDialog):
|
class Status_StatsDialog(MfxMessageDialog):
|
||||||
def __init__(self, parent, game):
|
def __init__(self, parent, game):
|
||||||
stats, gstats = game.stats, game.gstats
|
stats, gstats = game.stats, game.gstats
|
||||||
|
@ -595,7 +629,8 @@ class Status_StatsDialog(MfxMessageDialog):
|
||||||
n = n + len(s.cards)
|
n = n + len(s.cards)
|
||||||
w1 = (_("Highlight piles: ") + str(stats.highlight_piles) + "\n" +
|
w1 = (_("Highlight piles: ") + str(stats.highlight_piles) + "\n" +
|
||||||
_("Highlight cards: ") + str(stats.highlight_cards) + "\n" +
|
_("Highlight cards: ") + str(stats.highlight_cards) + "\n" +
|
||||||
_("Highlight same rank: ") + str(stats.highlight_samerank) + "\n")
|
_("Highlight same rank: ") + str(stats.highlight_samerank)
|
||||||
|
+ "\n")
|
||||||
if game.s.talon:
|
if game.s.talon:
|
||||||
if game.gameinfo.redeals != 0:
|
if game.gameinfo.redeals != 0:
|
||||||
w2 = w2 + _("\nRedeals: ") + str(game.s.talon.round - 1)
|
w2 = w2 + _("\nRedeals: ") + str(game.s.talon.round - 1)
|
||||||
|
@ -605,33 +640,37 @@ class Status_StatsDialog(MfxMessageDialog):
|
||||||
if game.s.foundations:
|
if game.s.foundations:
|
||||||
w2 = w2 + _("\nCards in Foundations: ") + str(n)
|
w2 = w2 + _("\nCards in Foundations: ") + str(n)
|
||||||
#
|
#
|
||||||
date = time.strftime("%Y-%m-%d %H:%M", time.localtime(game.gstats.start_time))
|
date = time.strftime(
|
||||||
MfxMessageDialog.__init__(self, parent, title=_("Game status"),
|
"%Y-%m-%d %H:%M",
|
||||||
text=game.getTitleName() + "\n" +
|
time.localtime(game.gstats.start_time))
|
||||||
game.getGameNumber(format=1) + "\n" +
|
MfxMessageDialog.__init__(
|
||||||
_("Playing time: ") + game.getTime() + "\n" +
|
self, parent, title=_("Game status"),
|
||||||
_("Started at: ") + date + "\n\n"+
|
text=game.getTitleName() + "\n" +
|
||||||
_("Moves: ") + str(game.moves.index) + "\n" +
|
game.getGameNumber(format=1) + "\n" +
|
||||||
_("Undo moves: ") + str(stats.undo_moves) + "\n" +
|
_("Playing time: ") + game.getTime() + "\n" +
|
||||||
_("Bookmark moves: ") + str(gstats.goto_bookmark_moves) + "\n" +
|
_("Started at: ") + date + "\n\n" +
|
||||||
_("Demo moves: ") + str(stats.demo_moves) + "\n" +
|
_("Moves: ") + str(game.moves.index) + "\n" +
|
||||||
_("Total player moves: ") + str(stats.player_moves) + "\n" +
|
_("Undo moves: ") + str(stats.undo_moves) + "\n" +
|
||||||
_("Total moves in this game: ") + str(stats.total_moves) + "\n" +
|
_("Bookmark moves: ") + str(gstats.goto_bookmark_moves) + "\n" +
|
||||||
_("Hints: ") + str(stats.hints) + "\n" +
|
_("Demo moves: ") + str(stats.demo_moves) + "\n" +
|
||||||
"\n" +
|
_("Total player moves: ") + str(stats.player_moves) + "\n" +
|
||||||
w1 + w2,
|
_("Total moves in this game: ") + str(stats.total_moves) + "\n" +
|
||||||
strings=(_("&OK"),
|
_("Hints: ") + str(stats.hints) + "\n" +
|
||||||
(_("&Statistics..."), 101),
|
"\n" +
|
||||||
(TOP_TITLE+"...", 105), ),
|
w1 + w2,
|
||||||
image=game.app.gimages.logos[3],
|
strings=(_("&OK"),
|
||||||
image_side="left", image_padx=20,
|
(_("&Statistics..."), 101),
|
||||||
padx=20,
|
(TOP_TITLE+"...", 105), ),
|
||||||
)
|
image=game.app.gimages.logos[3],
|
||||||
|
image_side="left", image_padx=20,
|
||||||
|
padx=20,
|
||||||
|
)
|
||||||
|
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
# *
|
# *
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
|
|
||||||
|
|
||||||
class _TopDialog(MfxDialog):
|
class _TopDialog(MfxDialog):
|
||||||
def __init__(self, parent, title, top, **kw):
|
def __init__(self, parent, title, top, **kw):
|
||||||
kw = self.initKw(kw)
|
kw = self.initKw(kw)
|
||||||
|
@ -671,7 +710,8 @@ class _TopDialog(MfxDialog):
|
||||||
l = Tkinter.Label(**cnf)
|
l = Tkinter.Label(**cnf)
|
||||||
l.grid(row=row, column=1, sticky='ew')
|
l.grid(row=row, column=1, sticky='ew')
|
||||||
# Start time
|
# Start time
|
||||||
t = time.strftime('%Y-%m-%d %H:%M', time.localtime(i.game_start_time))
|
t = time.strftime(
|
||||||
|
'%Y-%m-%d %H:%M', time.localtime(i.game_start_time))
|
||||||
cnf['text'] = t
|
cnf['text'] = t
|
||||||
l = Tkinter.Label(**cnf)
|
l = Tkinter.Label(**cnf)
|
||||||
l.grid(row=row, column=2, sticky='ew')
|
l.grid(row=row, column=2, sticky='ew')
|
||||||
|
@ -690,7 +730,6 @@ class _TopDialog(MfxDialog):
|
||||||
focus = self.createButtons(bottom_frame, kw)
|
focus = self.createButtons(bottom_frame, kw)
|
||||||
self.mainloop(focus, kw.timeout)
|
self.mainloop(focus, kw.timeout)
|
||||||
|
|
||||||
|
|
||||||
def initKw(self, kw):
|
def initKw(self, kw):
|
||||||
kw = KwStruct(kw, strings=(_('&OK'),), default=0, separator=True)
|
kw = KwStruct(kw, strings=(_('&OK'),), default=0, separator=True)
|
||||||
return MfxDialog.initKw(self, kw)
|
return MfxDialog.initKw(self, kw)
|
||||||
|
@ -710,12 +749,12 @@ class Top_StatsDialog(MfxDialog):
|
||||||
|
|
||||||
if (player in app.stats.games_stats and
|
if (player in app.stats.games_stats and
|
||||||
gameid in app.stats.games_stats[player] and
|
gameid in app.stats.games_stats[player] and
|
||||||
app.stats.games_stats[player][gameid].time_result.top):
|
app.stats.games_stats[player][gameid].time_result.top):
|
||||||
|
|
||||||
Tkinter.Label(frame, text=_('Minimum')).grid(row=0, column=1)
|
Tkinter.Label(frame, text=_('Minimum')).grid(row=0, column=1)
|
||||||
Tkinter.Label(frame, text=_('Maximum')).grid(row=0, column=2)
|
Tkinter.Label(frame, text=_('Maximum')).grid(row=0, column=2)
|
||||||
Tkinter.Label(frame, text=_('Average')).grid(row=0, column=3)
|
Tkinter.Label(frame, text=_('Average')).grid(row=0, column=3)
|
||||||
##Tkinter.Label(frame, text=_('Total')).grid(row=0, column=4)
|
# Tkinter.Label(frame, text=_('Total')).grid(row=0, column=4)
|
||||||
|
|
||||||
s = app.stats.games_stats[player][gameid]
|
s = app.stats.games_stats[player][gameid]
|
||||||
row = 1
|
row = 1
|
||||||
|
@ -742,24 +781,24 @@ class Top_StatsDialog(MfxDialog):
|
||||||
s.total_moves_result.top,
|
s.total_moves_result.top,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
## if s.score_result.min:
|
# if s.score_result.min:
|
||||||
## ll.append(('Score:',
|
# ll.append(('Score:',
|
||||||
## s.score_result.min,
|
# s.score_result.min,
|
||||||
## s.score_result.max,
|
# s.score_result.max,
|
||||||
## round(s.score_result.average, 2),
|
# round(s.score_result.average, 2),
|
||||||
## s.score_result.top,
|
# s.score_result.top,
|
||||||
## ))
|
# ))
|
||||||
## if s.score_casino_result.min:
|
# if s.score_casino_result.min:
|
||||||
## ll.append(('Casino Score:',
|
# ll.append(('Casino Score:',
|
||||||
## s.score_casino_result.min,
|
# s.score_casino_result.min,
|
||||||
## s.score_casino_result.max,
|
# s.score_casino_result.max,
|
||||||
## round(s.score_casino_result.average, 2), ))
|
# round(s.score_casino_result.average, 2), ))
|
||||||
for l, min, max, avr, tot, top in ll:
|
for l, min, max, avr, tot, top in ll:
|
||||||
Tkinter.Label(frame, text=l).grid(row=row, column=0)
|
Tkinter.Label(frame, text=l).grid(row=row, column=0)
|
||||||
Tkinter.Label(frame, text=str(min)).grid(row=row, column=1)
|
Tkinter.Label(frame, text=str(min)).grid(row=row, column=1)
|
||||||
Tkinter.Label(frame, text=str(max)).grid(row=row, column=2)
|
Tkinter.Label(frame, text=str(max)).grid(row=row, column=2)
|
||||||
Tkinter.Label(frame, text=str(avr)).grid(row=row, column=3)
|
Tkinter.Label(frame, text=str(avr)).grid(row=row, column=3)
|
||||||
##Tkinter.Label(frame, text=str(tot)).grid(row=row, column=4)
|
# Tkinter.Label(frame, text=str(tot)).grid(row=row, column=4)
|
||||||
b = Tkinter.Button(frame, text=TOP_TITLE+' ...', width=10,
|
b = Tkinter.Button(frame, text=TOP_TITLE+' ...', width=10,
|
||||||
command=lambda top=top: self.showTop(top))
|
command=lambda top=top: self.showTop(top))
|
||||||
b.grid(row=row, column=5)
|
b.grid(row=row, column=5)
|
||||||
|
@ -771,8 +810,8 @@ class Top_StatsDialog(MfxDialog):
|
||||||
self.mainloop(focus, kw.timeout)
|
self.mainloop(focus, kw.timeout)
|
||||||
|
|
||||||
def showTop(self, top):
|
def showTop(self, top):
|
||||||
#print top
|
# print top
|
||||||
d = _TopDialog(self.top, TOP_TITLE, top)
|
_TopDialog(self.top, TOP_TITLE, top)
|
||||||
|
|
||||||
def initKw(self, kw):
|
def initKw(self, kw):
|
||||||
kw = KwStruct(kw,
|
kw = KwStruct(kw,
|
||||||
|
@ -814,7 +853,7 @@ class ProgressionDialog(MfxDialog):
|
||||||
# constants
|
# constants
|
||||||
self.canvas_width, self.canvas_height = 600, 250
|
self.canvas_width, self.canvas_height = 600, 250
|
||||||
if parent.winfo_screenwidth() < 800 or \
|
if parent.winfo_screenwidth() < 800 or \
|
||||||
parent.winfo_screenheight() < 600:
|
parent.winfo_screenheight() < 600:
|
||||||
self.canvas_width, self.canvas_height = 400, 200
|
self.canvas_width, self.canvas_height = 400, 200
|
||||||
self.xmargin, self.ymargin = 10, 10
|
self.xmargin, self.ymargin = 10, 10
|
||||||
self.graph_dx, self.graph_dy = 10, 10
|
self.graph_dx, self.graph_dy = 10, 10
|
||||||
|
@ -863,18 +902,18 @@ class ProgressionDialog(MfxDialog):
|
||||||
# caption
|
# caption
|
||||||
d = self.text_height
|
d = self.text_height
|
||||||
x, y = self.xmargin, self.canvas_height-self.ymargin
|
x, y = self.xmargin, self.canvas_height-self.ymargin
|
||||||
id = canvas.create_rectangle(x, y, x+d, y-d, outline='black',
|
canvas.create_rectangle(x, y, x+d, y-d, outline='black',
|
||||||
fill=self.played_color)
|
fill=self.played_color)
|
||||||
x += d+5
|
x += d+5
|
||||||
canvas.create_text(x, y, anchor='sw', text=_('Played'))
|
canvas.create_text(x, y, anchor='sw', text=_('Played'))
|
||||||
x += measure(_('Played'))+20
|
x += measure(_('Played'))+20
|
||||||
id = canvas.create_rectangle(x, y, x+d, y-d, outline='black',
|
canvas.create_rectangle(x, y, x+d, y-d, outline='black',
|
||||||
fill=self.won_color)
|
fill=self.won_color)
|
||||||
x += d+5
|
x += d+5
|
||||||
canvas.create_text(x, y, anchor='sw', text=_('Won'))
|
canvas.create_text(x, y, anchor='sw', text=_('Won'))
|
||||||
x += measure(_('Won'))+20
|
x += measure(_('Won'))+20
|
||||||
id = canvas.create_rectangle(x, y, x+d, y-d, outline='black',
|
canvas.create_rectangle(x, y, x+d, y-d, outline='black',
|
||||||
fill=self.percent_color)
|
fill=self.percent_color)
|
||||||
x += d+5
|
x += d+5
|
||||||
canvas.create_text(x, y, anchor='sw', text=_('% won'))
|
canvas.create_text(x, y, anchor='sw', text=_('% won'))
|
||||||
|
|
||||||
|
@ -904,7 +943,7 @@ class ProgressionDialog(MfxDialog):
|
||||||
('month', _('Last month')),
|
('month', _('Last month')),
|
||||||
('year', _('Last year')),
|
('year', _('Last year')),
|
||||||
('all', _('All time')),
|
('all', _('All time')),
|
||||||
):
|
):
|
||||||
b = Tkinter.Radiobutton(label_frame, text=t, variable=var, value=v,
|
b = Tkinter.Radiobutton(label_frame, text=t, variable=var, value=v,
|
||||||
command=self.updateGraph,
|
command=self.updateGraph,
|
||||||
justify='left', anchor='w'
|
justify='left', anchor='w'
|
||||||
|
@ -942,12 +981,10 @@ class ProgressionDialog(MfxDialog):
|
||||||
focus = self.createButtons(bottom_frame, kw)
|
focus = self.createButtons(bottom_frame, kw)
|
||||||
self.mainloop(focus, kw.timeout)
|
self.mainloop(focus, kw.timeout)
|
||||||
|
|
||||||
|
|
||||||
def initKw(self, kw):
|
def initKw(self, kw):
|
||||||
kw = KwStruct(kw, strings=(_('&OK'),), default=0, separator=True)
|
kw = KwStruct(kw, strings=(_('&OK'),), default=0, separator=True)
|
||||||
return MfxDialog.initKw(self, kw)
|
return MfxDialog.initKw(self, kw)
|
||||||
|
|
||||||
|
|
||||||
def updateGraph(self, *args):
|
def updateGraph(self, *args):
|
||||||
interval = self.variable.get()
|
interval = self.variable.get()
|
||||||
canvas = self.canvas
|
canvas = self.canvas
|
||||||
|
@ -978,8 +1015,8 @@ class ProgressionDialog(MfxDialog):
|
||||||
xx = -100
|
xx = -100
|
||||||
for res in result:
|
for res in result:
|
||||||
if res[0] is not None and x > xx+self.text_width+4:
|
if res[0] is not None and x > xx+self.text_width+4:
|
||||||
##id = canvas.create_line(x, y0, x, y0-5, width=3)
|
# id = canvas.create_line(x, y0, x, y0-5, width=3)
|
||||||
##self.items.append(id)
|
# self.items.append(id)
|
||||||
id = canvas.create_line(x, y0, x, y1, stipple='gray50')
|
id = canvas.create_line(x, y0, x, y1, stipple='gray50')
|
||||||
self.items.append(id)
|
self.items.append(id)
|
||||||
id = canvas.create_text(x, y0+td, anchor='n', text=res[0])
|
id = canvas.create_text(x, y0+td, anchor='n', text=res[0])
|
||||||
|
@ -1016,15 +1053,15 @@ class ProgressionDialog(MfxDialog):
|
||||||
for res in result:
|
for res in result:
|
||||||
played, won = res[1], res[2]
|
played, won = res[1], res[2]
|
||||||
y = y0 - int(games_resolution*played)
|
y = y0 - int(games_resolution*played)
|
||||||
played_coords += [x,y]
|
played_coords += [x, y]
|
||||||
y = y0 - int(games_resolution*won)
|
y = y0 - int(games_resolution*won)
|
||||||
won_coords += [x,y]
|
won_coords += [x, y]
|
||||||
if played > 0:
|
if played > 0:
|
||||||
percent = int(100.*won/played)
|
percent = int(100.*won/played)
|
||||||
else:
|
else:
|
||||||
percent = 0
|
percent = 0
|
||||||
y = y0 - int(percent_resolution*percent)
|
y = y0 - int(percent_resolution*percent)
|
||||||
percent_coords += [x,y]
|
percent_coords += [x, y]
|
||||||
x += dx
|
x += dx
|
||||||
if self.played_graph_var.get():
|
if self.played_graph_var.get():
|
||||||
id = canvas.create_line(fill=self.played_color, width=3,
|
id = canvas.create_line(fill=self.played_color, width=3,
|
||||||
|
@ -1038,4 +1075,3 @@ class ProgressionDialog(MfxDialog):
|
||||||
id = canvas.create_line(fill=self.percent_color, width=3,
|
id = canvas.create_line(fill=self.percent_color, width=3,
|
||||||
*percent_coords)
|
*percent_coords)
|
||||||
self.items.append(id)
|
self.items.append(id)
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ my %skip =
|
||||||
|
|
||||||
# my $cmd = shell_quote( 'flake8', '.' );
|
# my $cmd = shell_quote( 'flake8', '.' );
|
||||||
my $cmd = shell_quote( 'flake8',
|
my $cmd = shell_quote( 'flake8',
|
||||||
grep { not exists $skip{$_} } glob('./*.py ./scripts/*.py ./tests/board_gen/*.py ./pysollib/*.py ./pysollib/[cmgpuw]*/{*/*.py,*.py} ./pysollib/tile/*.py ./pysollib/tk/{[a-sw],ta,ti,to,tkhtml}*.py ./pysollib/ui/tktile/*.py') );
|
grep { not exists $skip{$_} } glob('./*.py ./scripts/*.py ./tests/board_gen/*.py ./pysollib/*.py ./pysollib/[cmgpuw]*/{*/*.py,*.py} ./pysollib/tile/*.py ./pysollib/tk/{[a-sw],ta,ti,to,tkhtml,tkstats}*.py ./pysollib/ui/tktile/*.py') );
|
||||||
|
|
||||||
# TEST
|
# TEST
|
||||||
eq_or_diff( scalar(`$cmd`), '', "flake8 is happy with the code." );
|
eq_or_diff( scalar(`$cmd`), '', "flake8 is happy with the code." );
|
||||||
|
|
Loading…
Add table
Reference in a new issue