bpo-41831: Restore str implementation of __str__ in tkinter.EventType (GH-22355)

(cherry picked from commit eb38c6b7aa)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Miss Skeleton (bot) 2020-10-09 13:21:15 -07:00 committed by GitHub
parent 86938548d5
commit f8ebb7b62e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -185,8 +185,7 @@ class EventType(str, enum.Enum):
Deactivate = '37' Deactivate = '37'
MouseWheel = '38' MouseWheel = '38'
def __str__(self): __str__ = str.__str__
return self.name
class Event: class Event:
@ -266,7 +265,7 @@ class Event:
'num', 'delta', 'focus', 'num', 'delta', 'focus',
'x', 'y', 'width', 'height') 'x', 'y', 'width', 'height')
return '<%s event%s>' % ( return '<%s event%s>' % (
self.type, getattr(self.type, 'name', self.type),
''.join(' %s=%s' % (k, attrs[k]) for k in keys if k in attrs) ''.join(' %s=%s' % (k, attrs[k]) for k in keys if k in attrs)
) )

View File

@ -0,0 +1,3 @@
``str()`` for the ``type`` attribute of the ``tkinter.Event`` object always
returns now the numeric code returned by Tk instead of the name of the event
type.