summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-04-04 12:45:02 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-04-04 12:45:02 (GMT)
commitbcc174615ca2bd5fe60442407ca1411759d823cf (patch)
tree5d4b3ea30ef71af773e2576bfc7584ff25d230ff
parent578c9211d6b57bbb3cc00ba6dd55893814168695 (diff)
downloadcpython-bcc174615ca2bd5fe60442407ca1411759d823cf.zip
cpython-bcc174615ca2bd5fe60442407ca1411759d823cf.tar.gz
cpython-bcc174615ca2bd5fe60442407ca1411759d823cf.tar.bz2
Issue #20636: Improved the repr of Tkinter widgets.
-rw-r--r--Doc/library/turtle.rst2
-rw-r--r--Lib/tkinter/__init__.py5
-rw-r--r--Lib/tkinter/test/test_tkinter/test_misc.py5
-rw-r--r--Misc/NEWS2
4 files changed, 13 insertions, 1 deletions
diff --git a/Doc/library/turtle.rst b/Doc/library/turtle.rst
index b015530..0e3a979 100644
--- a/Doc/library/turtle.rst
+++ b/Doc/library/turtle.rst
@@ -1879,7 +1879,7 @@ Settings and special methods
>>> cv = screen.getcanvas()
>>> cv
- <turtle.ScrolledCanvas object at ...>
+ <turtle.ScrolledCanvas object ...>
.. function:: getshapes()
diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py
index 4ac4e57a..f60923a 100644
--- a/Lib/tkinter/__init__.py
+++ b/Lib/tkinter/__init__.py
@@ -1280,6 +1280,11 @@ class Misc:
def __str__(self):
"""Return the window path name of this widget."""
return self._w
+
+ def __repr__(self):
+ return '<%s.%s object %s>' % (
+ self.__class__.__module__, self.__class__.__qualname__, self._w)
+
# Pack methods that apply to the master
_noarg_ = ['_noarg_']
def pack_propagate(self, flag=_noarg_):
diff --git a/Lib/tkinter/test/test_tkinter/test_misc.py b/Lib/tkinter/test/test_tkinter/test_misc.py
index d325b31..46f5170 100644
--- a/Lib/tkinter/test/test_tkinter/test_misc.py
+++ b/Lib/tkinter/test/test_tkinter/test_misc.py
@@ -10,6 +10,11 @@ class MiscTest(unittest.TestCase):
def setUp(self):
self.root = ttk.setup_master()
+ def test_repr(self):
+ t = tkinter.Toplevel(self.root, name='top')
+ f = tkinter.Frame(t, name='child')
+ self.assertEqual(repr(f), '<tkinter.Frame object .top.child>')
+
def test_tk_setPalette(self):
root = self.root
root.tk_setPalette('black')
diff --git a/Misc/NEWS b/Misc/NEWS
index a1bb6c2..c8e84f4 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -29,6 +29,8 @@ Core and Builtins
Library
-------
+- Issue #20636: Improved the repr of Tkinter widgets.
+
- Issue #19505: The items, keys, and values views of OrderedDict now support
reverse iteration using reversed().