From e932dc7e2e45cdd56f7ef5148335f758dbb26a7b Mon Sep 17 00:00:00 2001 From: emkael Date: Sun, 23 Jun 2019 12:40:00 +0200 Subject: Refreshing match list dropdowns on match list change --- jfr_playoff/gui/frames/visual.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'jfr_playoff/gui/frames/visual.py') 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( + '<>', 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, -- cgit v1.2.3