[Tkinter-discuss] Event debugger

Vasilis Vlachoudis Vasilis.Vlachoudis at cern.ch
Mon Jan 5 14:57:12 CET 2015


Brilliant! This can be good to know

V.
________________________________________
From: Tkinter-discuss [tkinter-discuss-bounces+vasilis.vlachoudis=cern.ch at python.org] on behalf of Michael Lange [klappnase at web.de]
Sent: 05 January 2015 13:00
To: tkinter-discuss at python.org
Subject: Re: [Tkinter-discuss] Event debugger

Hi Vasilis,

On Mon, 5 Jan 2015 10:44:22 +0000
Vasilis Vlachoudis <Vasilis.Vlachoudis at cern.ch> wrote:

> Happy new year Mattias,
>
> Is it possible to use xev to monitor another window's events?

you can use this simple technique for that:

import Tkinter
from subprocess import Popen, PIPE
import fcntl
import os

root = Tkinter.Tk()

p = Popen(('xev', '-id', str(root.winfo_id())), stdout=PIPE)
fcntl.fcntl(p.stdout.fileno(), fcntl.F_SETFL, os.O_NONBLOCK)

def poll_events():
    try:
        out = p.stdout.read()
        print out
    except IOError:
        pass
    root.after(100, poll_events)
root.after(100, poll_events)
root.mainloop()

Unfortunately however, this way xev does *not* report mouse button
events, probably because of the limitation described at
http://www.rahul.net/kenton/events.html#LimitationsOf :

"Limitations of xev

Unfortunately, xev is not fool proof if you ask it to track events on a
window it does not own (the -id mode). It receives these events by
requesting them with Xlib's XSelectInput() function. This technique has
three major limitations:

    grabs - If one client activates a server, pointer, or keyboard grab,
then event reporting to all other clients will be affected. xev will not
be able to report some (or all) events, even though the client activating
the grab may be receiving them.

   non-maskable events - The X protocol does
not allow certain events to be reported to clients other than the one
that created the event window. Most of these events deal with selections.

   redirection events - The X protocol allows only one client to request
certain events. xev cannot receive these if another client is receiving
them. These events include window manager redirection events (e.g.,
substructure notify on the root window) and implicit passive grab events
(e.g., mouse button presses).

Users of xev must find alternate techniques for studying the above areas.
The xscope and xmon programs, discussed in the next section, may be
helpful. "

A happy new year to all of you, and best regards

Michael


.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

Live long and prosper.
                -- Spock, "Amok Time", stardate 3372.7
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss at python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss


More information about the Tkinter-discuss mailing list