summaryrefslogtreecommitdiff
path: root/jfr_playoff/gui/frames/match.py
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2019-12-27 21:29:04 +0100
committeremkael <emkael@tlen.pl>2019-12-27 21:29:04 +0100
commit33ea79bcaf780567a67f0cd6e7be8f5c49823bb0 (patch)
treefd94db305ec93d56b37946ecd0c09b3f88e11c39 /jfr_playoff/gui/frames/match.py
parentda515b8bbbd8b2d840920a6296f5d09f6c32414d (diff)
Restricting match selection in bracket GUI to current and previous phases only
Fixes #42
Diffstat (limited to 'jfr_playoff/gui/frames/match.py')
-rw-r--r--jfr_playoff/gui/frames/match.py29
1 files changed, 20 insertions, 9 deletions
diff --git a/jfr_playoff/gui/frames/match.py b/jfr_playoff/gui/frames/match.py
index 0dfd2aa..81bc06e 100644
--- a/jfr_playoff/gui/frames/match.py
+++ b/jfr_playoff/gui/frames/match.py
@@ -212,13 +212,23 @@ class MatchSelectionButton(SelectionButton):
@property
def errorMessage(self):
- return 'W turnieju nie zdefiniowano żadnych meczów'
+ return 'Brak meczów do wyboru'
+
+ def __init__(self, *args, **kwargs):
+ for arg in ['maxphase']:
+ setattr(self, arg, kwargs[arg] if arg in kwargs else None)
+ if arg in kwargs:
+ del kwargs[arg]
+ SelectionButton.__init__(self, *args, **kwargs)
def getOptions(self):
matches = self.winfo_toplevel().getMatches()
values = []
prev_match = None
for match in matches:
+ if self.maxphase is not None:
+ if match.getPhase() == self.maxphase:
+ break
if prev_match is not None:
if prev_match.getPhase() != match.getPhase():
values.append(None)
@@ -317,6 +327,10 @@ class BracketMatchSettingsFrame(GuiFrame):
allTeams = [team[0] for team in self.teamWidgets[0].getOptions()]
self.teams = [allTeams[idx-1] for idx in teams]
+ def getPhase(self):
+ obj = self.getSpecificParent(MatchSettingsFrame)
+ return obj.getPhase() if obj is not None else None
+
def renderContent(self):
self.source = NotifyIntVar()
self.source.trace('w', self._enablePanels)
@@ -351,12 +365,14 @@ class BracketMatchSettingsFrame(GuiFrame):
MatchSelectionButton(
self, prompt='Wybierz mecze:',
dialogclass=MatchSelectionFrame,
- callback=self._setWinners),
+ callback=self._setWinners,
+ maxphase=self.getPhase()),
ttk.Label(self, text='Przegrani meczów:'),
MatchSelectionButton(
self, prompt='Wybierz mecze:',
dialogclass=MatchSelectionFrame,
- callback=self._setLosers),
+ callback=self._setLosers,
+ maxphase=self.getPhase()),
ttk.Label(self, text='Pozycje początkowe:'),
TeamSelectionButton(
self, prompt='Wybierz pozycje początkowe:',
@@ -647,12 +663,7 @@ class MatchSettingsFrame(RepeatableFrame):
return self.matchID.get()
def getPhase(self):
- obj = self
- while not isinstance(obj, MatchPhaseFrame):
- obj = obj.master
- if obj is None:
- break
- return obj
+ return self.getSpecificParent(MatchPhaseFrame)
@property
def label(self):