Value holder for strings variables.
| 567 | |
| 568 | |
| 569 | class StringVar(Variable): |
| 570 | """Value holder for strings variables.""" |
| 571 | _default = "" |
| 572 | |
| 573 | def __init__(self, master=None, value=None, name=None): |
| 574 | """Construct a string variable. |
| 575 | |
| 576 | MASTER can be given as master widget. |
| 577 | VALUE is an optional value (defaults to "") |
| 578 | NAME is an optional Tcl name (defaults to PY_VARnum). |
| 579 | |
| 580 | If NAME matches an existing variable and VALUE is omitted |
| 581 | then the existing value is retained. |
| 582 | """ |
| 583 | Variable.__init__(self, master, value, name) |
| 584 | |
| 585 | def get(self): |
| 586 | """Return value of variable as string.""" |
| 587 | value = self._tk.globalgetvar(self._name) |
| 588 | if isinstance(value, str): |
| 589 | return value |
| 590 | return str(value) |
| 591 | |
| 592 | |
| 593 | class IntVar(Variable): |
no outgoing calls
searching dependent graphs…