1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
import json, os, sys
import tkinter as tk
from tkinter import ttk
from .tabs import *
class PlayoffGUI(tk.Tk):
def __init__(self):
tk.Tk.__init__(self)
ttk.Style().configure('TLabelframe.Label', foreground='black')
ttk.Style().configure('TLabelframe', padding=5)
self.geometry('920x640')
self.tabs = {}
self.newFileIndex = 0
self._title = tk.StringVar()
self._title.trace('w', self._setTitle)
self._dirty = False
self._filepath = None
def run(self):
self.notebook = ttk.Notebook(self)
self.notebook.pack(fill=tk.BOTH, expand=True)
for tab in tabs.__all__:
self.tabs[tab] = globals()[tab](self.notebook)
self.notebook.add(self.tabs[tab], text=self.tabs[tab].title)
if len(sys.argv) > 1:
self.openFile(sys.argv[1])
else:
self.newFile()
self.mainloop()
def _setValues(self, config):
for tab in self.tabs.values():
tab.setValues(config)
def _resetValues(self):
self._setValues({})
def newFile(self):
self._filepath = None
self.newFileIndex += 1
self._title.set('Nowa drabinka %d' % (self.newFileIndex))
self._resetValues()
def _setTitle(self, *args):
self.title('%s - %s%s' % (
'TeamyPlayOff',
self._title.get(),
'* ' if self._dirty else ''
))
def openFile(self, filepath):
self._filepath = filepath
self._title.set(os.path.basename(filepath))
self._setValues(json.load(open(filepath)))
def getDbConfig(self):
return self.tabs['NetworkTab'].getDB()
def getTeams(self):
return self.tabs['TeamsTab'].getTeams()
def getDBs(self):
return self.tabs['NetworkTab'].getDBList()
def getMatches(self):
return self.tabs['MatchesTab'].getMatches()
def getNewMatchID(self, match):
matches = self.tabs['MatchesTab'].getMatches()
if len(matches) > 0:
return max([m.getMatchID() for m in matches]) + 1
return 1
|