diff options
author | emkael <emkael@tlen.pl> | 2019-06-23 12:40:00 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2019-06-23 12:40:00 +0200 |
commit | e932dc7e2e45cdd56f7ef5148335f758dbb26a7b (patch) | |
tree | 52ebc2101861e0571b42f9a360337ed5866730c4 /jfr_playoff/gui/frames/__init__.py | |
parent | b8d98eb0e0f9fa7e695539164d61f90a271478d2 (diff) |
Refreshing match list dropdowns on match list change
Diffstat (limited to 'jfr_playoff/gui/frames/__init__.py')
-rw-r--r-- | jfr_playoff/gui/frames/__init__.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/jfr_playoff/gui/frames/__init__.py b/jfr_playoff/gui/frames/__init__.py index 4c4950e..50860b1 100644 --- a/jfr_playoff/gui/frames/__init__.py +++ b/jfr_playoff/gui/frames/__init__.py @@ -308,3 +308,21 @@ class SelectionFrame(ScrollableFrame): self.renderOption(container, option, idx) if self.selected and self.selected(idx, option): self.values[idx].set(True) + +class RefreshableOptionMenu(ttk.OptionMenu): + def __init__(self, *args, **kwargs): + ttk.OptionMenu.__init__(self, *args, **kwargs) + self.refreshOptions() + + def refreshOptions(self, *args): + oldValue = self._variable.get() + options = self.getOptions() + 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): + pass |