summaryrefslogtreecommitdiff
path: root/jfr_playoff/gui
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2022-03-13 12:35:16 +0100
committeremkael <emkael@tlen.pl>2022-03-13 12:35:16 +0100
commitf600c353167e5bac5076c4c0e9b82d39ce26077a (patch)
tree5ae2a36ba58fde39b7cb319a0c610f5f0650f019 /jfr_playoff/gui
parent400e1dd81c501775aa275a79332486badf82e380 (diff)
Float number type of GUI variable
Diffstat (limited to 'jfr_playoff/gui')
-rw-r--r--jfr_playoff/gui/variables.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/jfr_playoff/gui/variables.py b/jfr_playoff/gui/variables.py
index e76f503..d72f22e 100644
--- a/jfr_playoff/gui/variables.py
+++ b/jfr_playoff/gui/variables.py
@@ -13,6 +13,13 @@ class NotifyVar(tk.Variable):
self._root.event_generate('<<ValueChanged>>', when='tail')
self._prevValue = self.get()
+class FloatVar(tk.StringVar):
+ def get(self, default=None):
+ try:
+ return float(str(tk.StringVar.get(self)).strip())
+ except ValueError:
+ return default
+
class NumericVar(tk.StringVar):
def get(self, default=None):
try:
@@ -45,3 +52,8 @@ class NotifyNumericVar(NumericVar, NotifyVar):
def __init__(self, *args, **kwargs):
NotifyVar.__init__(self, *args, **kwargs)
NumericVar.__init__(self, *args, **kwargs)
+
+class NotifyFloatVar(FloatVar, NotifyVar):
+ def __init__(self, *args, **kwargs):
+ NotifyVar.__init__(self, *args, **kwargs)
+ FloatVar.__init__(self, *args, **kwargs)