summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2019-07-25 17:17:03 +0200
committeremkael <emkael@tlen.pl>2019-07-25 17:17:03 +0200
commite5620ec415e677603e0144e367dec938504c4c2d (patch)
tree5a6a1a9bdf643f85ce13b07b29873044df1c346f
parent749181b0b5c4ce554542f6c3213be31f39421240 (diff)
NumericVar without Notify features
-rw-r--r--jfr_playoff/gui/frames/__init__.py6
-rw-r--r--jfr_playoff/gui/variables.py15
2 files changed, 12 insertions, 9 deletions
diff --git a/jfr_playoff/gui/frames/__init__.py b/jfr_playoff/gui/frames/__init__.py
index f996263..3abdff5 100644
--- a/jfr_playoff/gui/frames/__init__.py
+++ b/jfr_playoff/gui/frames/__init__.py
@@ -7,7 +7,7 @@ import tkinter as tk
from tkinter import ttk
import tkMessageBox
-from ..variables import NotifyStringVar, NotifyIntVar, NotifyNumericVar
+from ..variables import NotifyStringVar, NotifyIntVar, NotifyNumericVar, NumericVar
def setPanelState(frame, state):
for child in frame.winfo_children():
@@ -467,9 +467,9 @@ class NumericSpinbox(tk.Spinbox):
self._default = kwargs['from_'] if 'from_' in kwargs else 0
tk.Spinbox.__init__(self, *args, **kwargs)
if self._variable is not None:
- if not isinstance(self._variable, NotifyNumericVar):
+ if not isinstance(self._variable, NumericVar):
raise AttributeError(
- 'NumericSpinbox variable must be NotifyNumericVar')
+ 'NumericSpinbox variable must be NumericVar')
self._variable.trace('w', self._onChange)
def _onChange(self, *args):
diff --git a/jfr_playoff/gui/variables.py b/jfr_playoff/gui/variables.py
index 8927179..e6877f2 100644
--- a/jfr_playoff/gui/variables.py
+++ b/jfr_playoff/gui/variables.py
@@ -13,15 +13,18 @@ class NotifyVar(tk.Variable):
self._root.event_generate('<<ValueChanged>>', when='tail')
self._prevValue = self.get()
+class NumericVar(tk.StringVar):
+ def get(self, default=None):
+ try:
+ return int(str(tk.StringVar.get(self)).strip())
+ except ValueError:
+ return default
+
class NotifyStringVar(NotifyVar, tk.StringVar):
pass
class NotifyIntVar(NotifyVar, tk.IntVar):
pass
-class NotifyNumericVar(NotifyStringVar):
- def get(self, default=None):
- try:
- return int(str(NotifyStringVar.get(self)).strip())
- except ValueError:
- return default
+class NotifyNumericVar(NotifyVar, NumericVar):
+ pass