[issue27294] Better repr for Tkinter event objects

2016-07-20 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Addendum: I verified flag 8 is Mod1 is Numlock on Windows.  
http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/event-handlers.html has table 
that claims that 8 is Left Alt and that 16 is NumLock. From what you say above, 
true on non-mac *nix, and only there.

Flag 32 is Mod3 = Scrolllock on Windows.

Question: autocomplete.py refers to event.mc_state in

if hasattr(event, "mc_state") and event.mc_state:
# A modifier was pressed along with the tab, continue as usual.
return

It is not mentioned as an event field in either the NMT ref or 
http://www.tcl.tk/man/tcl8.6/TkCmd/event.htm#M29.  However, it seems to be the 
state minus any 'lock' flags, Nun/Caps/Scrolllock on Windows.  It must use a 
system-specific mask.  The only Google hit for "tk event mc_state" is my recent 
commit of test_autocomplete.py.  Is this a normal tk event attribute or a local 
addition?

There is also mc_type, which is 0 for a tab combinations.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27294] Better repr for Tkinter event objects

2016-07-20 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
Removed message: http://bugs.python.org/msg268826

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27294] Better repr for Tkinter event objects

2016-07-20 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
Removed message: http://bugs.python.org/msg268824

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27294] Better repr for Tkinter event objects

2016-06-18 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

That's with this issue. I think we will return to Event repr after implementing 
named flags and providing standard mechanism for parsing and creating 
keystrokes (there are elements of this in IDLE).

--
resolution:  -> fixed
stage: commit review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27294] Better repr for Tkinter event objects

2016-06-18 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The last three commits actually are related to issue27079.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27294] Better repr for Tkinter event objects

2016-06-18 Thread Roundup Robot

Roundup Robot added the comment:

New changeset d7b6c07bc713 by Serhiy Storchaka in branch '3.5':
Issue #27294: Numerical state in the repr for Tkinter event objects is now
https://hg.python.org/cpython/rev/d7b6c07bc713

New changeset ac8338546ca8 by Serhiy Storchaka in branch '2.7':
Issue #27294: Numerical state in the repr for Tkinter event objects is now
https://hg.python.org/cpython/rev/ac8338546ca8

New changeset d03c8d0a6a73 by Serhiy Storchaka in branch 'default':
Issue #27294: Numerical state in the repr for Tkinter event objects is now
https://hg.python.org/cpython/rev/d03c8d0a6a73

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27294] Better repr for Tkinter event objects

2016-06-18 Thread Roundup Robot

Roundup Robot added the comment:

New changeset e0ec4abe659f by Serhiy Storchaka in branch 'default':
Issue #27294: Numerical state in the repr for Tkinter event objects is now
https://hg.python.org/cpython/rev/e0ec4abe659f

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27294] Better repr for Tkinter event objects

2016-06-18 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

According to Tk sources on Mac OSX: Mod1 is Command (=Meta), Mod2 is Option 
(=Alt), Mod3 is NumLock, Mod4 is Fn.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27294] Better repr for Tkinter event objects

2016-06-13 Thread Terry J. Reedy

Changes by Terry J. Reedy :


Added file: http://bugs.python.org/file43377/tk-win-key-events2.txt

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27294] Better repr for Tkinter event objects

2016-06-13 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you Terry, this information is helpful. Mod1 is Alt on X11, but not on 
Windows.

It looks to me that on Windows Mod1 is NumLock, Mod3 is ScrollLock, 0x2 is 
Alt, 0x4 is pad keyboard. It is not clear about Win. What events are 
emitted if your press say Win-X?

On Linux (X11) Mod1 is Alt, Mod2 is NumLock, Mod4 is Win, 0x2000, 0x4000 and 
0x6000 are alternative keyboard layouts. But many of this I presume is 
configurable.

Mac OS can have its own peculiarities.

I think on this stage it is better to left standard X11 modifiers (Shift, Lock, 
Control, Mod1-Mod5, Button1-Button5) and output the rest modifiers in 
hexadecimal. End user should interpret these names and numerics in platform 
depending way.

--
Added file: http://bugs.python.org/file43373/tkinter_event_repr_key_state2.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27294] Better repr for Tkinter event objects

2016-06-11 Thread Terry J. Reedy

Terry J. Reedy added the comment:

If you want more, say so, and I will do them after resting.

--
Added file: http://bugs.python.org/file43352/tk-win-key-events.txt

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27294] Better repr for Tkinter event objects

2016-06-11 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Next patch decodes the state attribute. Modifier names can be platform 
depended, please test on Windows. What modifiers correspond Shift, Ctrl, Alt, 
Win, CapsLock, etc?

--
Added file: http://bugs.python.org/file43349/tkinter_event_repr_key_state.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27294] Better repr for Tkinter event objects

2016-06-11 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 61a92a102b2d by Serhiy Storchaka in branch 'default':
Issue #27294: Improved repr for Tkinter event objects.
https://hg.python.org/cpython/rev/61a92a102b2d

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27294] Better repr for Tkinter event objects

2016-06-11 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Right.  This is why I suggested leaving anything we are not sure of to a later 
patch, after gaining more experience (and thought).

However, 'state' behaved strangely in my experiments.  In a sequence of about 
900 events, it started as 8 (Left Alt according to Shipman, but I never touched 
the key) and changed to 0 here







back to 8 here





and briefly back to 0 here






--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27294] Better repr for Tkinter event objects

2016-06-11 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The key state can be interesting for mouse events too. Ctrl-Click, Shift-Move. 
Maybe it is worth to omit the output of state=0.

Agreed, the 4 mouse positions are pretty noisy. Maybe omit root_x and root_y? 
But mouse position can be relevant for such key events as pressing Ctrl. For 
example if the mouse pointer points on module name in import statement, 
pressing Ctrl can convert the name into a hyperling to a file of the module.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27294] Better repr for Tkinter event objects

2016-06-11 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Summary: Though I would like to see some refinements, this looks really useful 
as is and I would like it applied soon even if refinements have to wait for a 
second patch.

Moving the window did not generate a printed event.

I like the compact way of handling customization.  Two more possible 
exclusions: 1. The key state seems like it should only be interesting for key 
events.  2. The 4 mouse positions are pretty noisy and seem not relevant to key 
events, and to many other non-mouse events.

I wish "VirtualEvent event"s had the triggering sequence available, but you 
cannot change that.
.

--
stage: patch review -> commit review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27294] Better repr for Tkinter event objects

2016-06-11 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Testing now.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27294] Better repr for Tkinter event objects

2016-06-11 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

If you have no something to add, I'll push the patch.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27294] Better repr for Tkinter event objects

2016-06-11 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Is this something that you might push before a2 tomorrow?  (If I review now?) 
Or still in development?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27294] Better repr for Tkinter event objects

2016-06-11 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Sorry yet once. Uploaded patch contained experimental implementation. Here is 
cleaned patch.

--
Added file: http://bugs.python.org/file43343/tkinter_event_repr.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27294] Better repr for Tkinter event objects

2016-06-11 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


Removed file: http://bugs.python.org/file43342/tkinter_event_repr.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27294] Better repr for Tkinter event objects

2016-06-11 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Oops! Sorry, here is a patch.

Event.type is decoded. The address of the Event object is omitted as don't 
having much sense (this is short-living object). The name of widget is omitted 
since it is too long and usually know (in any case you can easy print both 
widget and event). Only non-default set attributes are output (thus the output 
depends on the type of the event).

--
keywords: +patch
Added file: http://bugs.python.org/file43342/tkinter_event_repr.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27294] Better repr for Tkinter event objects

2016-06-11 Thread Terry J. Reedy

Terry J. Reedy added the comment:

+1! This would be helpful for exploration and quite possibly for tests.  
Earlier this year, I bound  to a custom function(event) printing 
event.x, event.y so I could discover how the line thickness of Canvas 
rectangles was distributed inside and outside the nominal dimensions. (Using a 
magnifier to click on exact pixels, I discovered the rule.) Being able to bind 
to print instead have been nice. 

There is no patch uploaded.  In the absence of seeing what you did... 
Event.type should be decoded.  The hex address should be replaced by at least 
the widget class, if not its path name (which would make readable names 
imperative!) The Event representation should be customized to the event type.

For me, there is no tkinter.EventType. The <> binding worked to 
prove the idea.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27294] Better repr for Tkinter event objects

2016-06-11 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Proposed patch adds better repr for tkinter.Event objects. Currently default 
repr shows only class name (always the same) and object address (not 
interesting, since event objects are short-living). The patch makes repr 
showing most event attributes in human-readable form.

For testing run following script. Press any keys (with modifiers), move and 
click mouse, select text, move and resize the window, switch to other windows.

import tkinter
t = tkinter.Text()
t.pack()
t.bind("<>", print)
t.bind("<>", print)
for k in tkinter.EventType:
try:
t.event_add("<>", '<%s>' % k)
except tkinter.TclError:
pass

tkinter.mainloop()

--
components: Tkinter
messages: 268209
nosy: serhiy.storchaka, terry.reedy
priority: normal
severity: normal
stage: patch review
status: open
title: Better repr for Tkinter event objects
type: enhancement
versions: Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com