summaryrefslogtreecommitdiff
path: root/jfr_playoff/gui/frames/__init__.py
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2019-06-28 01:33:24 +0200
committeremkael <emkael@tlen.pl>2019-06-28 01:33:24 +0200
commita46d3f05a9bc95932414ee8bc200e9d414d81487 (patch)
tree1ec39921d07c99af59035bcf872e08c853a9a00c /jfr_playoff/gui/frames/__init__.py
parente9780645ffc171ebc5323efcc84d970a435c3e5c (diff)
Remenbering last RefreshableOptionMenu value in a "sane" way
Diffstat (limited to 'jfr_playoff/gui/frames/__init__.py')
-rw-r--r--jfr_playoff/gui/frames/__init__.py18
1 files changed, 4 insertions, 14 deletions
diff --git a/jfr_playoff/gui/frames/__init__.py b/jfr_playoff/gui/frames/__init__.py
index 0165c71..dad25e5 100644
--- a/jfr_playoff/gui/frames/__init__.py
+++ b/jfr_playoff/gui/frames/__init__.py
@@ -339,7 +339,7 @@ class SelectionFrame(ScrollableFrame):
class RefreshableOptionMenu(ttk.OptionMenu):
def __init__(self, *args, **kwargs):
ttk.OptionMenu.__init__(self, *args, **kwargs)
- self._oldValue = self._variable.get()
+ self._lastValue = self._variable.get()
self._variable.trace('w', self._valueSet)
self._valueLock = False
self.refreshOptions()
@@ -351,7 +351,8 @@ class RefreshableOptionMenu(ttk.OptionMenu):
self['menu'].add_command(
label=option, command=tk._setit(self._variable, option))
self._valueLock = True
- self._variable.set(self._oldValue if self._oldValue in options else '')
+ self._variable.set(
+ self._lastValue if self._lastValue in options else '')
self._valueLock = False
def getOptions(self):
@@ -363,20 +364,9 @@ class RefreshableOptionMenu(ttk.OptionMenu):
def getValues(self):
pass
- def cmpValue(self, value):
- return self._variable.get() == self.getLabel(value)
-
def _valueSet(self, *args):
if not self._valueLock:
- self._valueLock = True
- self._oldValue = self._variable.get()
- for value in self.getValues():
- if self.cmpValue(value):
- self._variable.set(self.getLabel(value))
- self._valueLock = False
- return
- self._variable.set('')
- self._valueLock = False
+ self._lastValue = self._variable.get()
class TraceableText(tk.Text):
def __init__(self, *args, **kwargs):