Value holder for integer variables.
| 570 | |
| 571 | |
| 572 | class IntVar(Variable): |
| 573 | """Value holder for integer variables.""" |
| 574 | _default = 0 |
| 575 | |
| 576 | def __init__(self, master=None, value=None, name=None): |
| 577 | """Construct an integer variable. |
| 578 | |
| 579 | MASTER can be given as master widget. |
| 580 | VALUE is an optional value (defaults to 0) |
| 581 | NAME is an optional Tcl name (defaults to PY_VARnum). |
| 582 | |
| 583 | If NAME matches an existing variable and VALUE is omitted |
| 584 | then the existing value is retained. |
| 585 | """ |
| 586 | Variable.__init__(self, master, value, name) |
| 587 | |
| 588 | def get(self): |
| 589 | """Return the value of the variable as an integer.""" |
| 590 | value = self._tk.globalgetvar(self._name) |
| 591 | try: |
| 592 | return self._tk.getint(value) |
| 593 | except (TypeError, TclError): |
| 594 | return int(self._tk.getdouble(value)) |
| 595 | |
| 596 | |
| 597 | class DoubleVar(Variable): |
no outgoing calls