diff options
author | emkael <emkael@tlen.pl> | 2019-11-16 18:06:27 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2019-11-16 18:06:27 +0100 |
commit | e7e65d6ff541fa2fbf42ab58bc679b4b81124fd0 (patch) | |
tree | ed3fbb0bd3b3f69e2fba8ea34e08af50e0113567 /jfr_playoff | |
parent | 07b299a8cb5b84456efde0941af308a3b9c7bf3f (diff) |
Separating phases in match selection frame
Diffstat (limited to 'jfr_playoff')
-rw-r--r-- | jfr_playoff/gui/frames/match.py | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/jfr_playoff/gui/frames/match.py b/jfr_playoff/gui/frames/match.py index 15aa56c..e7f86fc 100644 --- a/jfr_playoff/gui/frames/match.py +++ b/jfr_playoff/gui/frames/match.py @@ -215,21 +215,37 @@ class MatchSelectionButton(SelectionButton): return 'W turnieju nie zdefiniowano żadnych meczów' def getOptions(self): - return self.winfo_toplevel().getMatches() + matches = self.winfo_toplevel().getMatches() + values = [] + prev_match = None + for match in matches: + if prev_match is not None: + if prev_match.getPhase() != match.getPhase(): + values.append(None) + values.append(match) + prev_match = match + return values class MatchSelectionFrame(SelectionFrame): def renderOption(self, container, option, idx): - (ttk.Label( - container, text='[%d]' % (self._mapValue(idx, option)))).grid( - row=idx+1, column=0) - (ttk.Checkbutton( - container, text=option.label, - variable=self.values[self._mapValue(idx, option)] - )).grid(row=idx+1, column=1, sticky=tk.W) + if option is not None: + (ttk.Label( + container, text='[%d]' % (self._mapValue(idx, option)))).grid( + row=idx+1, column=0) + (ttk.Checkbutton( + container, text=option.label, + variable=self.values[self._mapValue(idx, option)] + )).grid(row=idx+1, column=1, sticky=tk.W) + else: + (ttk.Separator( + container, orient=tk.HORIZONTAL)).grid( + row=idx+1, column=0, columnspan=2, + sticky=tk.E+tk.W, pady=2) def _mapValue(self, idx, value): - return self.options[idx].getMatchID() + if self.options[idx] is not None: + return self.options[idx].getMatchID() class SelectedTeamList(RefreshableOptionMenu): @@ -379,7 +395,8 @@ class BracketMatchSettingsFrame(GuiFrame): matches = [ match.getMatchID() for match in self.bracketWidgets[ - self.LIST_WIDGETS['winner']].getOptions()] + self.LIST_WIDGETS['winner']].getOptions() + if match is not None] self.bracketWidgets[self.LIST_WIDGETS['winner']].setPositions([ winner for winner in self.winners if winner in matches]) self.bracketWidgets[self.LIST_WIDGETS['loser']].setPositions([ @@ -629,7 +646,7 @@ class MatchSettingsFrame(RepeatableFrame): def getMatchID(self): return self.matchID.get() - def _getPhase(self): + def getPhase(self): obj = self while not isinstance(obj, MatchPhaseFrame): obj = obj.master @@ -640,7 +657,7 @@ class MatchSettingsFrame(RepeatableFrame): @property def label(self): try: - phase = self._getPhase() + phase = self.getPhase() return 'Mecz #%d [faza: %s]' % ( self.getMatchID(), phase.master.tab(phase)['text'].strip() |