Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Lib/tkinter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,7 @@ class EventType(str, enum.Enum):
Deactivate = '37',
MouseWheel = '38',

def __str__(self):
return self.name
__str__ = str.__str__

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is unnecessary if subclassing the new StrEnum, which my patch did. Just remove the def __str__ and we're good.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, this is exactly the change we want for 3.8 and 3.9.



class Event:
Expand Down Expand Up @@ -266,7 +265,7 @@ def __repr__(self):
'num', 'delta', 'focus',
'x', 'y', 'width', 'height')
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)
)

Expand Down
Original file line number Diff line number Diff line change
@@ -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.