Value holder for strings variables.
| 546 | |
| 547 | |
| 548 | class StringVar(Variable): |
| 549 | """Value holder for strings variables.""" |
| 550 | _default = "" |
| 551 | |
| 552 | def __init__(self, master=None, value=None, name=None): |
| 553 | """Construct a string variable. |
| 554 | |
| 555 | MASTER can be given as master widget. |
| 556 | VALUE is an optional value (defaults to "") |
| 557 | NAME is an optional Tcl name (defaults to PY_VARnum). |
| 558 | |
| 559 | If NAME matches an existing variable and VALUE is omitted |
| 560 | then the existing value is retained. |
| 561 | """ |
| 562 | Variable.__init__(self, master, value, name) |
| 563 | |
| 564 | def get(self): |
| 565 | """Return value of variable as string.""" |
| 566 | value = self._tk.globalgetvar(self._name) |
| 567 | if isinstance(value, str): |
| 568 | return value |
| 569 | return str(value) |
| 570 | |
| 571 | |
| 572 | class IntVar(Variable): |
no outgoing calls