summaryrefslogtreecommitdiff
path: root/jfr_playoff/gui/frames/match.py
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2019-06-28 01:25:03 +0200
committeremkael <emkael@tlen.pl>2019-06-28 01:25:03 +0200
commit903ace218bbc5a16a4f42479024d1702bf54e29f (patch)
tree3b936cb225049e97aa0e573696949b66b12c563e /jfr_playoff/gui/frames/match.py
parente53d7c6e35e8bb7aab42976f470957dde313ece5 (diff)
Updating winner/loser matches options on match list change
Diffstat (limited to 'jfr_playoff/gui/frames/match.py')
-rw-r--r--jfr_playoff/gui/frames/match.py19
1 files changed, 18 insertions, 1 deletions
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(
'<<TeamListChanged>>', self._onTeamListChange, add='+')
+ self.winfo_toplevel().bind(
+ '<<MatchListChanged>>', 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]