summaryrefslogtreecommitdiff
path: root/jfr_playoff/gui
diff options
context:
space:
mode:
Diffstat (limited to 'jfr_playoff/gui')
-rw-r--r--jfr_playoff/gui/__init__.py6
-rw-r--r--jfr_playoff/gui/tabs.py41
2 files changed, 38 insertions, 9 deletions
diff --git a/jfr_playoff/gui/__init__.py b/jfr_playoff/gui/__init__.py
index 79a1fad..5737ab6 100644
--- a/jfr_playoff/gui/__init__.py
+++ b/jfr_playoff/gui/__init__.py
@@ -15,3 +15,9 @@ class PlayoffGUI(tk.Tk):
self.tabs[tab] = globals()[tab](self.notebook)
self.notebook.add(self.tabs[tab], text=self.tabs[tab].title)
self.mainloop()
+
+ def getDbConfig(self):
+ return self.tabs['NetworkTab'].getDB()
+
+ def getTeams(self):
+ return self.tabs['TeamsTab'].getTeams()
diff --git a/jfr_playoff/gui/tabs.py b/jfr_playoff/gui/tabs.py
index bbcb4b0..3bf08b6 100644
--- a/jfr_playoff/gui/tabs.py
+++ b/jfr_playoff/gui/tabs.py
@@ -8,6 +8,8 @@ import tkFileDialog as tkfd
from .frames.team import *
+from ..data import PlayoffData
+
class PlayoffTab(ttk.Frame):
def __init__(self, master):
ttk.Frame.__init__(self, master)
@@ -97,20 +99,38 @@ class TeamsTab(PlayoffTab):
return 'Uczestnicy'
def renderContent(self, container):
- settingsFrame = TeamSettingsFrame(container, padx=5, pady=5)
- settingsFrame.grid(row=0, column=0, sticky=tk.N+tk.E+tk.S+tk.W)
- settingsFrame.columnconfigure(2, weight=1)
- previewFrame = TeamPreviewFrame(container)
- previewFrame.grid(row=0, column=1, rowspan=2,
- sticky=tk.N+tk.E+tk.W)
- aliasFrame = TeamAliasFrame(container)
- aliasFrame.grid(row=1, column=0,
- sticky=tk.N+tk.E+tk.S+tk.W)
+ self.settingsFrame = TeamSettingsFrame(container, padx=5, pady=5)
+ self.settingsFrame.grid(row=0, column=0, sticky=tk.N+tk.E+tk.S+tk.W)
+ self.settingsFrame.columnconfigure(2, weight=1)
+ self.previewFrame = TeamPreviewFrame(container)
+ self.previewFrame.grid(row=0, column=1, rowspan=2,
+ sticky=tk.N+tk.E+tk.W)
+ self.aliasFrame = TeamAliasFrame(container)
+ self.aliasFrame.grid(row=1, column=0,
+ sticky=tk.N+tk.E+tk.S+tk.W)
container.columnconfigure(0, weight=1)
container.columnconfigure(1, weight=3)
container.rowconfigure(0, weight=2)
container.rowconfigure(1, weight=1)
+ def getTeams(self):
+ config = self.collectConfig()
+ dbConfig = self.winfo_toplevel().getDbConfig()
+ if dbConfig is not None:
+ config['database'] = dbConfig
+ data = PlayoffData()
+ return data.fetch_team_list(config['teams'], dbConfig)
+
+ def collectConfig(self):
+ config = {
+ 'teams': self.settingsFrame.getConfig(),
+ 'team_aliases': self.aliasFrame.getConfig()
+ }
+ tieConfig = self.previewFrame.getTieConfig()
+ if tieConfig is not None and isinstance(config['teams'], dict):
+ config['teams']['ties'] = tieConfig
+ return config
+
class MatchesTab(PlayoffTab):
@property
def title(self):
@@ -126,6 +146,9 @@ class NetworkTab(PlayoffTab):
def title(self):
return 'Sieć'
+ def getDB(self):
+ return None
+
class VisualTab(PlayoffTab):
@property
def title(self):