From c0f4f1210b9686fb9e79935673ca1b8a4e9bf7c8 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 27 Dec 2019 20:58:02 +0100 Subject: Proper change notifications for widget repeater and selection button/frame Fixes #41 --- jfr_playoff/gui/variables.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'jfr_playoff/gui/variables.py') diff --git a/jfr_playoff/gui/variables.py b/jfr_playoff/gui/variables.py index 7e6989c..ac9e0a6 100644 --- a/jfr_playoff/gui/variables.py +++ b/jfr_playoff/gui/variables.py @@ -20,16 +20,22 @@ class NumericVar(tk.StringVar): except ValueError: return default +class BoolVar(tk.StringVar): + def get(self, *args, **kwargs): + value = tk.StringVar.get(self, *args, **kwargs) + return int(value == '1') + + def set(self, value, *args, **kwargs): + return tk.StringVar.set(self, '1' if value else '0', *args, **kwargs) + class NotifyStringVar(NotifyVar, tk.StringVar): pass class NotifyIntVar(NotifyVar, tk.IntVar): pass -class NotifyBoolVar(NotifyVar, tk.StringVar): - def get(self, *args, **kwargs): - value = tk.StringVar.get(self, *args, **kwargs) - return int(value == '1') +class NotifyBoolVar(NotifyVar, BoolVar): + pass class NotifyNumericVar(NumericVar, NotifyVar): def __init__(self, *args, **kwargs): -- cgit v1.2.3