summaryrefslogtreecommitdiff
path: root/jfr_playoff/gui/frames
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2019-06-07 01:45:03 +0200
committeremkael <emkael@tlen.pl>2019-06-07 01:45:03 +0200
commitd2a80e738bf9d2f4a8aeb4d9ecfeee15900798ae (patch)
tree5658b9a3f8677d6517c1b54290c28a36bb669bfb /jfr_playoff/gui/frames
parent12f8ec126e38407fc0cf3f936bde913f0811b4b6 (diff)
DB selection field is now universal
Diffstat (limited to 'jfr_playoff/gui/frames')
-rw-r--r--jfr_playoff/gui/frames/team.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/jfr_playoff/gui/frames/team.py b/jfr_playoff/gui/frames/team.py
index a24aa0b..c446d05 100644
--- a/jfr_playoff/gui/frames/team.py
+++ b/jfr_playoff/gui/frames/team.py
@@ -131,6 +131,16 @@ class TeamSelectionButton(ttk.Button):
selectionFrame.pack(fill=tk.BOTH, expand=True, padx=5, pady=5)
+class DBSelectionField(ttk.OptionMenu):
+ def setOptions(self, values):
+ if self._variable.get() not in values:
+ self._variable.set('')
+ menu = self['menu']
+ menu.delete(0, tk.END)
+ for item in values:
+ menu.add_command(
+ label=item, command=tk._setit(self._variable, item))
+
class TeamFetchSettingsFrame(GuiFrame):
SOURCE_LINK = 0
SOURCE_DB = 1
@@ -156,16 +166,8 @@ class TeamFetchSettingsFrame(GuiFrame):
teams['max_teams'] = maxTeams
return teams
- def _createDBList(self, values):
- if self.fetchDB.get() not in values:
- self.fetchDB.set('')
- self.fetchDBField = ttk.OptionMenu(
- self, self.fetchDB, self.fetchDB.get(), *values)
- self.fetchDBField.grid(row=0, column=3, sticky=tk.W+tk.E)
-
def _onDBListChange(self, *args):
- self.fetchDBField.destroy()
- self._createDBList(self.winfo_toplevel().getDBs())
+ self.fetchDBField.setOptions(self.winfo_toplevel().getDBs())
def _sourceChange(self, *args):
self.fetchDBField.configure(state=tk.DISABLED)
@@ -187,9 +189,12 @@ class TeamFetchSettingsFrame(GuiFrame):
row=0, column=1, columnspan=2, sticky=tk.W)
self.fetchDB = tk.StringVar()
self.fetchDB.trace('w', self._changeNotify)
- self._createDBList([])
+ self.fetchDBField = DBSelectionField(
+ self, self.fetchDB, self.fetchDB.get())
+ self.fetchDBField.grid(row=0, column=3, sticky=tk.W+tk.E)
self.winfo_toplevel().bind(
'<<DBListChanged>>', self._onDBListChange, add='+')
+ self.fetchDBField.setOptions([])
(ttk.Radiobutton(
self, text='Strona wyników',