diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2024-05-07 12:07:32 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-07 12:07:32 (GMT) |
commit | 65f5e586a1239ed1a66d8284773d7b02ce40e480 (patch) | |
tree | 2df752dc79daf89283ed5b01c1b9a8a37abed9a3 /Lib/tkinter | |
parent | b60d4c0d53b6aafbf4a6e560b4cb6f1d5c7240c8 (diff) | |
download | cpython-65f5e586a1239ed1a66d8284773d7b02ce40e480.zip cpython-65f5e586a1239ed1a66d8284773d7b02ce40e480.tar.gz cpython-65f5e586a1239ed1a66d8284773d7b02ce40e480.tar.bz2 |
gh-66410: Do not stringify arguments of Tkinter callback (GH-98592)
Callbacks registered in the tkinter module now take arguments as
various Python objects (int, float, bytes, tuple), not just str.
To restore the previous behavior set tkinter module global wantobject to 1
before creating the Tk object or call the wantobject() method of the Tk object
with argument 1.
Calling it with argument 2 restores the current default behavior.
Diffstat (limited to 'Lib/tkinter')
-rw-r--r-- | Lib/tkinter/__init__.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py index dc6ee9a..daecf4e 100644 --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -40,7 +40,7 @@ TclError = _tkinter.TclError from tkinter.constants import * import re -wantobjects = 1 +wantobjects = 2 _debug = False # set to True to print executed Tcl/Tk commands TkVersion = float(_tkinter.TK_VERSION) @@ -1762,7 +1762,10 @@ class Misc: try: e.type = EventType(T) except ValueError: - e.type = T + try: + e.type = EventType(str(T)) # can be int + except ValueError: + e.type = T try: e.widget = self._nametowidget(W) except KeyError: |