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.py8
-rw-r--r--jfr_playoff/gui/frames/visual.py16
3 files changed, 39 insertions, 3 deletions
diff --git a/jfr_playoff/gui/frames/__init__.py b/jfr_playoff/gui/frames/__init__.py
index 4c4950e..50860b1 100644
--- a/jfr_playoff/gui/frames/__init__.py
+++ b/jfr_playoff/gui/frames/__init__.py
@@ -308,3 +308,21 @@ class SelectionFrame(ScrollableFrame):
self.renderOption(container, option, idx)
if self.selected and self.selected(idx, option):
self.values[idx].set(True)
+
+class RefreshableOptionMenu(ttk.OptionMenu):
+ def __init__(self, *args, **kwargs):
+ ttk.OptionMenu.__init__(self, *args, **kwargs)
+ self.refreshOptions()
+
+ def refreshOptions(self, *args):
+ oldValue = self._variable.get()
+ options = self.getOptions()
+ self['menu'].delete(0, tk.END)
+ for option in options:
+ self['menu'].add_command(
+ label=option, command=tk._setit(self._variable, option))
+ if oldValue not in options:
+ self._variable.set('')
+
+ def getOptions(self):
+ pass
diff --git a/jfr_playoff/gui/frames/match.py b/jfr_playoff/gui/frames/match.py
index 6772e6b..ceaeec2 100644
--- a/jfr_playoff/gui/frames/match.py
+++ b/jfr_playoff/gui/frames/match.py
@@ -163,7 +163,7 @@ class MatchSelectionFrame(SelectionFrame):
(ttk.Label(container, text='[%d]' % (idx+1))).grid(
row=idx+1, column=0)
(ttk.Checkbutton(
- container, text='Mecz nr %d' % (option.getMatchID()),
+ container, text=option.label,
variable=self.values[idx]
)).grid(row=idx+1, column=1, sticky=tk.W)
@@ -360,6 +360,8 @@ class MatchSettingsFrame(RepeatableFrame):
self.source.set(self.SCORE_SOURCE_CUSTOM)
+ self.winfo_toplevel().event_generate(
+ '<<MatchListChanged>>', when='tail')
@classmethod
def info(cls):
@@ -368,6 +370,10 @@ class MatchSettingsFrame(RepeatableFrame):
def getMatchID(self):
return self.matchID
+ @property
+ def label(self):
+ return 'Mecz nr %d' % (self.getMatchID())
+
class MatchSeparator(RepeatableFrame):
def renderContent(self):
(ttk.Separator(self, orient=tk.HORIZONTAL)).pack(
diff --git a/jfr_playoff/gui/frames/visual.py b/jfr_playoff/gui/frames/visual.py
index b36a5ec..372f02f 100644
--- a/jfr_playoff/gui/frames/visual.py
+++ b/jfr_playoff/gui/frames/visual.py
@@ -6,7 +6,7 @@ import tkColorChooser as tkcc
from ..frames import GuiFrame, RepeatableFrame, ScrollableFrame
from ..frames import WidgetRepeater
-from ..frames import SelectionFrame
+from ..frames import SelectionFrame, RefreshableOptionMenu
from ..frames.team import TeamSelectionButton
class VisualSettingsFrame(GuiFrame):
@@ -141,13 +141,25 @@ class VisualSettingsFrame(GuiFrame):
field.configure(state=tk.NORMAL if var.get() else tk.DISABLED)
+class MatchList(RefreshableOptionMenu):
+ def __init__(self, *args, **kwargs):
+ RefreshableOptionMenu.__init__(self, *args, **kwargs)
+ self.winfo_toplevel().bind(
+ '<<MatchListChanged>>', self.refreshOptions, add='+')
+ self.configure(width=10)
+
+ def getOptions(self):
+ return [match.label for match in self.winfo_toplevel().getMatches()]
+
+
class BoxPositionFrame(RepeatableFrame):
def renderContent(self):
self.match = tk.StringVar()
self.vertical = tk.IntVar()
self.horizontal = tk.IntVar()
self.horizontal.set(-1)
- (ttk.OptionMenu(self, self.match)).grid(row=0, column=0)
+ self.matchBox = MatchList(self, self.match)
+ self.matchBox.grid(row=0, column=0)
(ttk.Label(self, text=' w pionie:')).grid(row=0, column=1)
(tk.Spinbox(
self, textvariable=self.vertical, from_=0, to=9999,