diff options
author | emkael <emkael@tlen.pl> | 2019-06-28 01:33:24 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2019-06-28 01:33:24 +0200 |
commit | a46d3f05a9bc95932414ee8bc200e9d414d81487 (patch) | |
tree | 1ec39921d07c99af59035bcf872e08c853a9a00c | |
parent | e9780645ffc171ebc5323efcc84d970a435c3e5c (diff) |
Remenbering last RefreshableOptionMenu value in a "sane" way
-rw-r--r-- | jfr_playoff/gui/frames/__init__.py | 18 | ||||
-rw-r--r-- | jfr_playoff/gui/frames/visual.py | 5 |
2 files changed, 4 insertions, 19 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): diff --git a/jfr_playoff/gui/frames/visual.py b/jfr_playoff/gui/frames/visual.py index 37cb90c..28d1827 100644 --- a/jfr_playoff/gui/frames/visual.py +++ b/jfr_playoff/gui/frames/visual.py @@ -178,7 +178,6 @@ class VisualSettingsFrame(GuiFrame): self.teamNamePrefix.set(values['team_boxes']['name_prefix']) - class MatchList(RefreshableOptionMenu): def __init__(self, *args, **kwargs): RefreshableOptionMenu.__init__(self, *args, **kwargs) @@ -192,9 +191,6 @@ class MatchList(RefreshableOptionMenu): def getValues(self): return self.winfo_toplevel().getMatches() - def cmpValue(self, match): - return match.id == getIntVal(self._variable, 0) - class BoxPositionFrame(RepeatableFrame): def renderContent(self): @@ -214,7 +210,6 @@ class BoxPositionFrame(RepeatableFrame): self, textvariable=self.horizontal, from_=-1, to=9999, width=5, justify=tk.RIGHT)).grid( row=0, column=4) - self.setValue([]) def setValue(self, value): |