mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Added date format option to statistics.
This commit is contained in:
parent
c16921cf9a
commit
7f7c710973
2 changed files with 31 additions and 8 deletions
|
@ -282,7 +282,7 @@ class ProgressionFormatter:
|
|||
t = list(t)+[0, 0, 0, -1, -1, -1]
|
||||
return list(time.localtime(time.mktime(tuple(t))))
|
||||
|
||||
def getResults(self, interval, all_games=True):
|
||||
def getResults(self, interval, all_games=True, date_format='%d.%m'):
|
||||
if all_games:
|
||||
results = self.all_results
|
||||
else:
|
||||
|
@ -293,7 +293,7 @@ class ProgressionFormatter:
|
|||
lt = self.norm_time(t)
|
||||
marks = None
|
||||
delta = 1
|
||||
format = '%d.%m'
|
||||
format = date_format
|
||||
elif interval == 'month':
|
||||
tt = t[:]
|
||||
t[1] -= 1
|
||||
|
@ -304,7 +304,7 @@ class ProgressionFormatter:
|
|||
tt[2] -= 10
|
||||
marks.append(self.norm_time(tt)[:3])
|
||||
delta = 1
|
||||
format = '%d.%m'
|
||||
format = date_format
|
||||
elif interval == 'year':
|
||||
tt = t[:]
|
||||
t[0] -= 1
|
||||
|
@ -314,7 +314,7 @@ class ProgressionFormatter:
|
|||
tt[1] -= 2
|
||||
marks.append(self.norm_time(tt)[:3])
|
||||
delta = 7
|
||||
format = '%d.%m.%y'
|
||||
format = date_format
|
||||
else: # all
|
||||
tt = t[:]
|
||||
tt[1] -= 1
|
||||
|
@ -339,7 +339,7 @@ class ProgressionFormatter:
|
|||
t = self.norm_time(t)
|
||||
marks.append(t[:3])
|
||||
delta = 7
|
||||
format = '%d.%m.%y'
|
||||
format = date_format
|
||||
|
||||
res = []
|
||||
ct = list(time.localtime())
|
||||
|
|
|
@ -889,8 +889,9 @@ class ProgressionFrame(ttk.Frame):
|
|||
variable=var, value='current',
|
||||
command=self.updateGraph)
|
||||
b.pack(fill='x', expand=True, padx=3, pady=1)
|
||||
|
||||
label_frame = ttk.LabelFrame(right_frame, text=_('Statistics for'))
|
||||
label_frame.pack(side='top', fill='x', pady=10)
|
||||
label_frame.pack(side='top', fill='x', pady=5)
|
||||
self.variable = var = tkinter.StringVar()
|
||||
var.set('week')
|
||||
for v, t in (
|
||||
|
@ -902,8 +903,9 @@ class ProgressionFrame(ttk.Frame):
|
|||
b = ttk.Radiobutton(label_frame, text=t, variable=var,
|
||||
value=v, command=self.updateGraph)
|
||||
b.pack(fill='x', expand=True, padx=3, pady=1)
|
||||
|
||||
label_frame = ttk.LabelFrame(right_frame, text=_('Show graphs'))
|
||||
label_frame.pack(side='top', fill='x')
|
||||
label_frame.pack(side='top', fill='x', pady=5)
|
||||
self.played_graph_var = tkinter.BooleanVar()
|
||||
self.played_graph_var.set(True)
|
||||
b = ttk.Checkbutton(label_frame, text=_('Played'),
|
||||
|
@ -923,6 +925,21 @@ class ProgressionFrame(ttk.Frame):
|
|||
variable=self.percent_graph_var)
|
||||
b.pack(fill='x', expand=True, padx=3, pady=1)
|
||||
|
||||
label_frame = ttk.LabelFrame(right_frame, text=_('Date format'))
|
||||
label_frame.pack(side='top', fill='x', pady=5)
|
||||
self.date_format = tkinter.StringVar()
|
||||
self.date_format.set('%m-%d')
|
||||
b = ttk.Radiobutton(label_frame, text=_('MM-DD'),
|
||||
command=self.updateGraph,
|
||||
variable=self.date_format,
|
||||
value='%m-%d')
|
||||
b.pack(fill='x', expand=True, padx=3, pady=1)
|
||||
b = ttk.Radiobutton(label_frame, text=_('DD-MM'),
|
||||
command=self.updateGraph,
|
||||
variable=self.date_format,
|
||||
value='%d-%m')
|
||||
b.pack(fill='x', expand=True, padx=3, pady=1)
|
||||
|
||||
# self.createGraph()
|
||||
bind(canvas, '<Map>', self.createGraph)
|
||||
|
||||
|
@ -997,14 +1014,20 @@ class ProgressionFrame(ttk.Frame):
|
|||
self.items = []
|
||||
|
||||
all_games = (self.all_games_variable.get() == 'all')
|
||||
result = self.formatter.getResults(interval, all_games)
|
||||
|
||||
date_format = self.date_format.get()
|
||||
|
||||
if interval in ('week', 'month'):
|
||||
t = _('Games/day')
|
||||
else:
|
||||
t = _('Games/week')
|
||||
date_format += '-%y'
|
||||
|
||||
canvas.itemconfig(self.games_text_id, text=t)
|
||||
|
||||
result = self.formatter.getResults(interval, all_games,
|
||||
date_format)
|
||||
|
||||
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)
|
||||
|
|
Loading…
Add table
Reference in a new issue