From 903ace218bbc5a16a4f42479024d1702bf54e29f Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 28 Jun 2019 01:25:03 +0200 Subject: Updating winner/loser matches options on match list change --- jfr_playoff/gui/frames/match.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'jfr_playoff/gui/frames/match.py') diff --git a/jfr_playoff/gui/frames/match.py b/jfr_playoff/gui/frames/match.py index a7d46b2..01cb742 100644 --- a/jfr_playoff/gui/frames/match.py +++ b/jfr_playoff/gui/frames/match.py @@ -285,6 +285,8 @@ class BracketMatchSettingsFrame(GuiFrame): self._lockTeams = True self.winfo_toplevel().bind( '<>', self._onTeamListChange, add='+') + self.winfo_toplevel().bind( + '<>', self._onMatchListChange, add='+') buttons = [ ttk.Radiobutton( @@ -326,7 +328,7 @@ class BracketMatchSettingsFrame(GuiFrame): for idx, widget in enumerate(self.bracketWidgets): widget.grid(row=1+idx/2, column=1+idx%2, sticky=tk.W) - self._lockTeams = True + self._lockTeams = False def _onTeamListChange(self, *args): teamsToSet = [] @@ -340,6 +342,21 @@ class BracketMatchSettingsFrame(GuiFrame): self.teamWidgets[0].setPositions(teamsToSet) self._lockTeams = False + def _onMatchListChange(self, *args): + try: + matches = [ + match.getMatchID() for match + in self.bracketWidgets[ + self.LIST_WIDGETS['winner']].getOptions()] + self.bracketWidgets[self.LIST_WIDGETS['winner']].setPositions([ + winner for winner in self.winners if winner in matches]) + self.bracketWidgets[self.LIST_WIDGETS['loser']].setPositions([ + loser for loser in self.losers if loser in matches]) + except tk.TclError as e: + # we're probably trying to update our widget when + # WE'RE the match that's being destroyed + pass + def setValue(self, value): if isinstance(value, (str, unicode)): value = [value] -- cgit v1.2.3