From 2efa8b15abd451c31b377ff3de975ade8d24516c Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 21 Jun 2019 18:13:07 +0200 Subject: Position/team selection buttons and frames made reusable and extendable --- jfr_playoff/gui/frames/match.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 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 9c7dfc7..922e4cf 100644 --- a/jfr_playoff/gui/frames/match.py +++ b/jfr_playoff/gui/frames/match.py @@ -6,7 +6,9 @@ from tkinter import ttk from ..frames import GuiFrame, RepeatableFrame, ScrollableFrame from ..frames import WidgetRepeater, RepeatableEntry, getIntVal -from ..frames.team import DBSelectionField +from ..frames import SelectionFrame, SelectionButton +from ..frames.team import DBSelectionField, TeamList, TeamSelectionButton +from ..frames.visual import PositionsSelectionFrame class SwissSettingsFrame(RepeatableFrame): SOURCE_LINK = 0 @@ -139,3 +141,31 @@ class SwissesFrame(ScrollableFrame): self.swisses.pack(side=tk.TOP, fill=tk.BOTH, expand=True) __all__ = ['SwissesFrame'] + +class MatchSelectionButton(SelectionButton): + @property + def defaultPrompt(self): + return 'Wybierz mecze:' + + @property + def title(self): + return 'Wybór meczów' + + @property + def errorMessage(self): + return 'W turnieju nie zdefiniowano żadnych meczów' + + def getOptions(self): + return self.winfo_toplevel().getMatches() + + +class MatchSelectionFrame(SelectionFrame): + def renderOption(self, container, option, idx): + (ttk.Label(container, text='[%d]' % (idx+1))).grid( + row=idx+1, column=0) + (ttk.Checkbutton( + container, text='Mecz nr %d' % (option.getMatchID()), + variable=self.values[idx] + )).grid(row=idx+1, column=1, sticky=tk.W) + + -- cgit v1.2.3