summaryrefslogtreecommitdiff
path: root/jfr_playoff/gui/frames/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'jfr_playoff/gui/frames/__init__.py')
-rw-r--r--jfr_playoff/gui/frames/__init__.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/jfr_playoff/gui/frames/__init__.py b/jfr_playoff/gui/frames/__init__.py
index dba30a5..9939626 100644
--- a/jfr_playoff/gui/frames/__init__.py
+++ b/jfr_playoff/gui/frames/__init__.py
@@ -315,6 +315,8 @@ class RefreshableOptionMenu(ttk.OptionMenu):
def __init__(self, *args, **kwargs):
ttk.OptionMenu.__init__(self, *args, **kwargs)
self.refreshOptions()
+ self._variable.trace('w', self._valueSet)
+ self._valueLock = False
def refreshOptions(self, *args):
oldValue = self._variable.get()
@@ -327,8 +329,28 @@ class RefreshableOptionMenu(ttk.OptionMenu):
self._variable.set('')
def getOptions(self):
+ return [self.getLabel(value) for value in self.getValues()]
+
+ def getLabel(self, value):
+ pass
+
+ def getValues(self):
pass
+ def cmpValue(self, value):
+ return self._variable.get().strip() == self.getLabel(value)
+
+ def _valueSet(self, *args):
+ if not self._valueLock:
+ self._valueLock = True
+ for idx, value in self.getValues():
+ if self.cmpValue(value):
+ self._variable.set(self.getLabel(value))
+ self._valueLock = False
+ return
+ self._variable.set('')
+ self._valueLock = False
+
class TraceableText(tk.Text):
def __init__(self, *args, **kwargs):
self._variable = None