diff options
author | emkael <emkael@tlen.pl> | 2019-06-23 12:39:37 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2019-06-23 12:39:37 +0200 |
commit | b8d98eb0e0f9fa7e695539164d61f90a271478d2 (patch) | |
tree | a4656041a021788784eaaa628b32def491a886f4 /jfr_playoff | |
parent | 5cdfee5a5e402a0213ae0bca3aa9290a0263402c (diff) |
Reusable refreshable menu option list
Diffstat (limited to 'jfr_playoff')
-rw-r--r-- | jfr_playoff/gui/frames/team.py | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/jfr_playoff/gui/frames/team.py b/jfr_playoff/gui/frames/team.py index 9056070..28ffeba 100644 --- a/jfr_playoff/gui/frames/team.py +++ b/jfr_playoff/gui/frames/team.py @@ -6,7 +6,7 @@ from tkinter import ttk from ..frames import GuiFrame, RepeatableFrame, ScrollableFrame from ..frames import WidgetRepeater, RepeatableEntry -from ..frames import SelectionButton, SelectionFrame +from ..frames import SelectionButton, SelectionFrame, RefreshableOptionMenu from ..frames import getIntVal, setPanelState class ManualTeamRow(RepeatableFrame): @@ -276,23 +276,15 @@ class TeamSettingsFrame(ScrollableFrame): return self.fetchSettingsFrame.getTeams() return [] -class TeamList(ttk.OptionMenu): +class TeamList(RefreshableOptionMenu): def __init__(self, *args, **kwargs): - ttk.OptionMenu.__init__(self, *args, **kwargs) + RefreshableOptionMenu.__init__(self, *args, **kwargs) self.winfo_toplevel().bind( - '<<TeamListChanged>>', self._refreshTeams, add='+') - self._refreshTeams(None) + '<<TeamListChanged>>', self.refreshOptions, add='+') self.configure(width=10) - def _refreshTeams(self, event): - oldValue = self._variable.get() - options = [team[0] for team in self.winfo_toplevel().getTeams()] - self['menu'].delete(0, tk.END) - for option in options: - self['menu'].add_command( - label=option, command=tk._setit(self._variable, option)) - if oldValue not in options: - self._variable.set('') + def getOptions(self): + return [team[0] for team in self.winfo_toplevel().getTeams()] class TeamAliasRow(RepeatableFrame): def renderContent(self): |