diff options
author | emkael <emkael@tlen.pl> | 2019-12-27 20:58:02 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2019-12-27 20:58:02 +0100 |
commit | c0f4f1210b9686fb9e79935673ca1b8a4e9bf7c8 (patch) | |
tree | c3ee823e2a018f45472d7804e4e6b3731c750dfd /jfr_playoff/gui/variables.py | |
parent | c9090b822d731c52594b48a80550588e277d394a (diff) |
Proper change notifications for widget repeater and selection button/frame
Fixes #41
Diffstat (limited to 'jfr_playoff/gui/variables.py')
-rw-r--r-- | jfr_playoff/gui/variables.py | 14 |
1 files changed, 10 insertions, 4 deletions
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): |