summaryrefslogtreecommitdiff
path: root/jfr_playoff/gui/frames
diff options
context:
space:
mode:
Diffstat (limited to 'jfr_playoff/gui/frames')
-rw-r--r--jfr_playoff/gui/frames/__init__.py18
-rw-r--r--jfr_playoff/gui/frames/match.py10
-rw-r--r--jfr_playoff/gui/frames/team.py7
-rw-r--r--jfr_playoff/gui/frames/visual.py4
4 files changed, 24 insertions, 15 deletions
diff --git a/jfr_playoff/gui/frames/__init__.py b/jfr_playoff/gui/frames/__init__.py
index 7f30a31..270bbbd 100644
--- a/jfr_playoff/gui/frames/__init__.py
+++ b/jfr_playoff/gui/frames/__init__.py
@@ -293,7 +293,7 @@ class SelectionButton(ttk.Button):
selectionFrame = self.dialogclass(
dialog, title=self.prompt,
options=options,
- selected=lambda idx, option: idx+1 in self.selected,
+ selected=self.selected,
callback=self.setPositions, vertical=True)
selectionFrame.pack(fill=tk.BOTH, expand=True, padx=5, pady=5)
@@ -304,7 +304,7 @@ class SelectionFrame(ScrollableFrame):
def __init__(self, master, title='', options=[],
selected=None, callback=None, *args, **kwargs):
- self.values = []
+ self.values = {}
self.title = title
self.options = options
self.selected = selected
@@ -313,11 +313,14 @@ class SelectionFrame(ScrollableFrame):
(ttk.Button(master, text='Zapisz', command=self._save)).pack(
side=tk.BOTTOM, fill=tk.Y)
+ def _mapValue(self, idx, value):
+ return idx + 1
+
def _save(self):
if self.callback:
self.callback(
- [idx+1 for idx, value
- in enumerate(self.values) if value.get()])
+ [idx for idx, value
+ in self.values.iteritems() if value.get()])
self.master.destroy()
def renderHeader(self, container):
@@ -328,10 +331,11 @@ class SelectionFrame(ScrollableFrame):
def renderContent(self, container):
self.renderHeader(container)
for idx, option in enumerate(self.options):
- self.values.append(tk.IntVar())
+ key = self._mapValue(idx, option)
+ self.values[key] = tk.IntVar()
self.renderOption(container, option, idx)
- if self.selected and self.selected(idx, option):
- self.values[idx].set(True)
+ if self.selected and key in self.selected:
+ self.values[key].set(True)
class RefreshableOptionMenu(ttk.OptionMenu):
def __init__(self, *args, **kwargs):
diff --git a/jfr_playoff/gui/frames/match.py b/jfr_playoff/gui/frames/match.py
index aa06b8b..6487e23 100644
--- a/jfr_playoff/gui/frames/match.py
+++ b/jfr_playoff/gui/frames/match.py
@@ -192,13 +192,17 @@ class MatchSelectionButton(SelectionButton):
class MatchSelectionFrame(SelectionFrame):
def renderOption(self, container, option, idx):
- (ttk.Label(container, text='[%d]' % (idx+1))).grid(
- row=idx+1, column=0)
+ (ttk.Label(
+ container, text='[%d]' % (self._mapValue(idx, option)))).grid(
+ row=idx+1, column=0)
(ttk.Checkbutton(
container, text=option.label,
- variable=self.values[idx]
+ variable=self.values[self._mapValue(idx, option)]
)).grid(row=idx+1, column=1, sticky=tk.W)
+ def _mapValue(self, idx, value):
+ return self.options[idx].getMatchID()
+
class BracketMatchSettingsFrame(GuiFrame):
SOURCE_TEAM=0
diff --git a/jfr_playoff/gui/frames/team.py b/jfr_playoff/gui/frames/team.py
index 8d789b9..a304040 100644
--- a/jfr_playoff/gui/frames/team.py
+++ b/jfr_playoff/gui/frames/team.py
@@ -58,11 +58,12 @@ class TeamManualSettingsFrame(GuiFrame):
class TeamSelectionFrame(SelectionFrame):
def renderOption(self, container, option, idx):
- (ttk.Label(container, text='[%d]' % (idx+1))).grid(
- row=idx+1, column=0)
+ (ttk.Label(
+ container, text='[%d]' % (self._mapValue(idx, option)))).grid(
+ row=idx+1, column=0)
(ttk.Checkbutton(
container, text=option[0],
- variable=self.values[idx]
+ variable=self.values[self._mapValue(idx, option)]
)).grid(row=idx+1, column=1, sticky=tk.W)
class TeamSelectionButton(SelectionButton):
diff --git a/jfr_playoff/gui/frames/visual.py b/jfr_playoff/gui/frames/visual.py
index 2f6a5a2..37cb90c 100644
--- a/jfr_playoff/gui/frames/visual.py
+++ b/jfr_playoff/gui/frames/visual.py
@@ -335,8 +335,8 @@ class PositionsSelectionFrame(SelectionFrame):
def renderOption(self, container, option, idx):
(ttk.Checkbutton(
- container, text=str(idx+1),
- variable=self.values[idx]
+ container, text=str(self._mapValue(idx, option)),
+ variable=self.values[self._mapValue(idx, option)]
)).grid(
row=(idx/self.COLUMN_COUNT)+1, column=idx%self.COLUMN_COUNT,
sticky=tk.W)