summaryrefslogtreecommitdiff
path: root/jfr_playoff/gui/variables.py
blob: abb3cc15ece6ace5d3aae1f2221d9c4fc0fa3802 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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