summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2003-04-16 20:10:03 (GMT)
committerGuido van Rossum <guido@python.org>2003-04-16 20:10:03 (GMT)
commit2cd0a65c708d6120487f161f9039b981a03ae20b (patch)
tree68a378ed6b383b5b51a31caea7bd1ea4f641d141
parenta4541a30fcd101c6c6ed83a55d13c505f97378d8 (diff)
downloadcpython-2cd0a65c708d6120487f161f9039b981a03ae20b.zip
cpython-2cd0a65c708d6120487f161f9039b981a03ae20b.tar.gz
cpython-2cd0a65c708d6120487f161f9039b981a03ae20b.tar.bz2
Add 'get' method to Variable and switch it from internal class to
standard class (it is now useful because it doesn't constrain the type of the value).
-rw-r--r--Lib/lib-tk/Tkinter.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/lib-tk/Tkinter.py b/Lib/lib-tk/Tkinter.py
index bd36d10..2a822a1 100644
--- a/Lib/lib-tk/Tkinter.py
+++ b/Lib/lib-tk/Tkinter.py
@@ -163,7 +163,10 @@ def _exit(code='0'):
_varnum = 0
class Variable:
- """Internal class. Base class to define value holders for e.g. buttons."""
+ """Class to define value holders for e.g. buttons.
+
+ Subclasses StringVar, IntVar, DoubleVar, BooleanVar are specializations
+ that constrain the type of the value returned from get()."""
_default = ""
def __init__(self, master=None):
"""Construct a variable with an optional MASTER as master widget.
@@ -186,6 +189,9 @@ class Variable:
def set(self, value):
"""Set the variable to VALUE."""
return self._tk.globalsetvar(self._name, value)
+ def get(self):
+ """Return value of variable."""
+ return self._tk.globalgetvar(self._name)
def trace_variable(self, mode, callback):
"""Define a trace callback for the variable.