summaryrefslogtreecommitdiff
path: root/jfr_playoff/gui/frames/__init__.py
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2019-06-27 16:15:34 +0200
committeremkael <emkael@tlen.pl>2019-06-27 16:15:34 +0200
commita3ad9e2147311ed5e2afbba0375cd95374c0217a (patch)
tree9e07ebf479b995f4df91a4f53003d38f5a5fb516 /jfr_playoff/gui/frames/__init__.py
parent07ff0371f6cd1434fc3fdf11181954967a9d888b (diff)
Fixes for value setting in option lists
Diffstat (limited to 'jfr_playoff/gui/frames/__init__.py')
-rw-r--r--jfr_playoff/gui/frames/__init__.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/jfr_playoff/gui/frames/__init__.py b/jfr_playoff/gui/frames/__init__.py
index 9939626..1e86e64 100644
--- a/jfr_playoff/gui/frames/__init__.py
+++ b/jfr_playoff/gui/frames/__init__.py
@@ -314,19 +314,20 @@ class SelectionFrame(ScrollableFrame):
class RefreshableOptionMenu(ttk.OptionMenu):
def __init__(self, *args, **kwargs):
ttk.OptionMenu.__init__(self, *args, **kwargs)
- self.refreshOptions()
+ self._oldValue = self._variable.get()
self._variable.trace('w', self._valueSet)
self._valueLock = False
+ 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('')
+ self._valueLock = True
+ self._variable.set(self._oldValue if self._oldValue in options else '')
+ self._valueLock = False
def getOptions(self):
return [self.getLabel(value) for value in self.getValues()]
@@ -338,12 +339,13 @@ class RefreshableOptionMenu(ttk.OptionMenu):
pass
def cmpValue(self, value):
- return self._variable.get().strip() == self.getLabel(value)
+ return self._variable.get() == self.getLabel(value)
def _valueSet(self, *args):
if not self._valueLock:
self._valueLock = True
- for idx, value in self.getValues():
+ self._oldValue = self._variable.get()
+ for value in self.getValues():
if self.cmpValue(value):
self._variable.set(self.getLabel(value))
self._valueLock = False