Value holder for integer variables.
| 591 | |
| 592 | |
| 593 | class IntVar(Variable): |
| 594 | """Value holder for integer variables.""" |
| 595 | _default = 0 |
| 596 | |
| 597 | def __init__(self, master=None, value=None, name=None): |
| 598 | """Construct an integer variable. |
| 599 | |
| 600 | MASTER can be given as master widget. |
| 601 | VALUE is an optional value (defaults to 0) |
| 602 | NAME is an optional Tcl name (defaults to PY_VARnum). |
| 603 | |
| 604 | If NAME matches an existing variable and VALUE is omitted |
| 605 | then the existing value is retained. |
| 606 | """ |
| 607 | Variable.__init__(self, master, value, name) |
| 608 | |
| 609 | def get(self): |
| 610 | """Return the value of the variable as an integer.""" |
| 611 | value = self._tk.globalgetvar(self._name) |
| 612 | try: |
| 613 | return self._tk.getint(value) |
| 614 | except (TypeError, TclError): |
| 615 | return int(self._tk.getdouble(value)) |
| 616 | |
| 617 | |
| 618 | class DoubleVar(Variable): |
no outgoing calls
searching dependent graphs…