Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
9c6c3fb4
Commit
9c6c3fb4
authored
Jun 18, 2016
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #27294: Numerical state in the repr for Tkinter event objects is now
represented as a compination of known flags.
parent
45ff4a54
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
8 deletions
+24
-8
Lib/tkinter/__init__.py
Lib/tkinter/__init__.py
+21
-8
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/tkinter/__init__.py
View file @
9c6c3fb4
...
@@ -220,28 +220,41 @@ class Event:
...
@@ -220,28 +220,41 @@ class Event:
delta - delta of wheel movement (MouseWheel)
delta - delta of wheel movement (MouseWheel)
"""
"""
def __repr__(self):
def __repr__(self):
state
= {k: v for k, v in self.__dict__.items() if v != '??'}
attrs
= {k: v for k, v in self.__dict__.items() if v != '??'}
if not self.char:
if not self.char:
del
state
['char']
del
attrs
['char']
elif self.char != '??':
elif self.char != '??':
state
['char'] = repr(self.char)
attrs
['char'] = repr(self.char)
if not getattr(self, 'send_event', True):
if not getattr(self, 'send_event', True):
del
state
['send_event']
del
attrs
['send_event']
if self.state == 0:
if self.state == 0:
del state['state']
del attrs['state']
elif isinstance(self.state, int):
state = self.state
mods = ('Shift', 'Lock', 'Control',
'Mod1', 'Mod2', 'Mod3', 'Mod4', 'Mod5',
'Button1', 'Button2', 'Button3', 'Button4', 'Button5')
s = []
for i, n in enumerate(mods):
if state & (1 << i):
s.append(n)
state = state & ~((1<< len(mods)) - 1)
if state or not s:
s.append(hex(state))
attrs['state'] = '|'.join(s)
if self.delta == 0:
if self.delta == 0:
del
state
['delta']
del
attrs
['delta']
# widget usually is known
# widget usually is known
# serial and time are not very interesing
# serial and time are not very interesing
# keysym_num duplicates keysym
# keysym_num duplicates keysym
# x_root and y_root mostly duplicate x and y
# x_root and y_root mostly duplicate x and y
keys = ('send_event',
keys = ('send_event',
'state', 'key
code', 'char', 'keysym
',
'state', 'key
sym', 'keycode', 'char
',
'num', 'delta', 'focus',
'num', 'delta', 'focus',
'x', 'y', 'width', 'height')
'x', 'y', 'width', 'height')
return '<%s event%s>' % (
return '<%s event%s>' % (
self.type,
self.type,
''.join(' %s=%s' % (k,
state[k]) for k in keys if k in state
)
''.join(' %s=%s' % (k,
attrs[k]) for k in keys if k in attrs
)
)
)
_support_default_root = 1
_support_default_root = 1
...
...
Misc/NEWS
View file @
9c6c3fb4
...
@@ -10,6 +10,9 @@ What's New in Python 3.6.0 alpha 3
...
@@ -10,6 +10,9 @@ What's New in Python 3.6.0 alpha 3
Library
Library
-------
-------
- Issue #27294: Numerical state in the repr for Tkinter event objects is now
represented as a compination of known flags.
- Issue #27177: Match objects in the re module now support index-like objects
- Issue #27177: Match objects in the re module now support index-like objects
as group indices. Based on patches by Jeroen Demeyer and Xiang Zhang.
as group indices. Based on patches by Jeroen Demeyer and Xiang Zhang.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment