mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
[3.12] gh-113877: Fix Tkinter method winfo_pathname() on 64-bit Windows (GH-113900) (GH-113901)
winfo_id() converts the result of "winfo id" command to integer, but
"winfo pathname" command requires an argument to be a hexadecimal number
on Win64.
(cherry picked from commit 1b7e0024a1
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
159e3db1f7
commit
7530c612d1
3 changed files with 15 additions and 0 deletions
|
@ -227,6 +227,18 @@ class MiscTest(AbstractTkTest, unittest.TestCase):
|
||||||
with self.assertRaises(tkinter.TclError):
|
with self.assertRaises(tkinter.TclError):
|
||||||
rgb((111, 78, 55))
|
rgb((111, 78, 55))
|
||||||
|
|
||||||
|
def test_winfo_pathname(self):
|
||||||
|
t = tkinter.Toplevel(self.root)
|
||||||
|
w = tkinter.Button(t)
|
||||||
|
wid = w.winfo_id()
|
||||||
|
self.assertIsInstance(wid, int)
|
||||||
|
self.assertEqual(self.root.winfo_pathname(hex(wid)), str(w))
|
||||||
|
self.assertEqual(self.root.winfo_pathname(hex(wid), displayof=None), str(w))
|
||||||
|
self.assertEqual(self.root.winfo_pathname(hex(wid), displayof=t), str(w))
|
||||||
|
self.assertEqual(self.root.winfo_pathname(wid), str(w))
|
||||||
|
self.assertEqual(self.root.winfo_pathname(wid, displayof=None), str(w))
|
||||||
|
self.assertEqual(self.root.winfo_pathname(wid, displayof=t), str(w))
|
||||||
|
|
||||||
def test_event_repr_defaults(self):
|
def test_event_repr_defaults(self):
|
||||||
e = tkinter.Event()
|
e = tkinter.Event()
|
||||||
e.serial = 12345
|
e.serial = 12345
|
||||||
|
|
|
@ -1181,6 +1181,8 @@ class Misc:
|
||||||
|
|
||||||
def winfo_pathname(self, id, displayof=0):
|
def winfo_pathname(self, id, displayof=0):
|
||||||
"""Return the pathname of the widget given by ID."""
|
"""Return the pathname of the widget given by ID."""
|
||||||
|
if isinstance(id, int):
|
||||||
|
id = hex(id)
|
||||||
args = ('winfo', 'pathname') \
|
args = ('winfo', 'pathname') \
|
||||||
+ self._displayof(displayof) + (id,)
|
+ self._displayof(displayof) + (id,)
|
||||||
return self.tk.call(args)
|
return self.tk.call(args)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fix :mod:`tkinter` method ``winfo_pathname()`` on 64-bit Windows.
|
Loading…
Add table
Add a link
Reference in a new issue