summaryrefslogtreecommitdiff
path: root/jfr_playoff/gui/frames/__init__.py
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2019-06-27 14:26:47 +0200
committeremkael <emkael@tlen.pl>2019-06-27 14:26:47 +0200
commit07ff0371f6cd1434fc3fdf11181954967a9d888b (patch)
tree2c577360c945515bec89dda7518d87f413b9c318 /jfr_playoff/gui/frames/__init__.py
parent106133121d017c1788cde11c2d419b74e5465979 (diff)
Setting values for MatchList/TeamList unified
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