diff options
author | emkael <emkael@tlen.pl> | 2019-07-07 20:45:05 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2019-07-07 20:45:05 +0200 |
commit | 4f55701e1b291a9a6da9eb7aef5802e6bc20cbf0 (patch) | |
tree | 8468abc56148f0abd27ac3e2bc40961ddd8d4c11 /jfr_playoff/gui/variables.py | |
parent | e563236fb07628dfec57f7cd887b63f4d87e2067 (diff) |
Numeric values and spinboxes handled in custom widget
Diffstat (limited to 'jfr_playoff/gui/variables.py')
-rw-r--r-- | jfr_playoff/gui/variables.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/jfr_playoff/gui/variables.py b/jfr_playoff/gui/variables.py new file mode 100644 index 0000000..abb3cc1 --- /dev/null +++ b/jfr_playoff/gui/variables.py @@ -0,0 +1,24 @@ +#coding=utf-8 + +import tkinter as tk + +class NotifyVar(tk.Variable): + def __init__(self, *args, **kwargs): + tk.Variable.__init__(self, *args, **kwargs) + self.trace('w', self._onChange) + + def _onChange(self, *args): + self._root.event_generate('<<ValueChanged>>', when='tail') + +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 |