On Tue, 2002-05-14 at 16:08, Christian Reis wrote:
> On Sun, May 12, 2002 at 02:56:30AM -0400, Evan Hughes wrote:
> >
> >   How can I detect whenever the user hits a key or moves the mouse?
> 
> Added FAQ questions 3.2, 3.3 and 3.4:
> 
> http://www.async.com.br/faq/pygtk/index.py?req=index

Very nice, thanks. Is it okay for anybody (who's confident of the
answer) to update the FAQ with the wizard, or are there a few people who
take responsibility for keeping it current?

I ask because there is a bug in the example code in 3.2; the print
statement in wakeup() has bad variable substitution formats in it. This
would do nicely (for PyGTK 0.6.x):

    def wakeup( widget, event, *args ):
        print "Event %d woke me up" % event.type

I think that question 3.3 might benefit from a link to the GtkEventBox
widget too, incase people are trying to bind events to a widget that
doesn't have it's own X window.

I notice that to capture a key press you don't specify
GDK.KEY_PRESS_MASK, yet you can still connect the window to the
key_press_event. Why does this work? 

My reading of the docs lead me to believe that you need to do this:

    w.add_events(GDK.KEY_PRESS_MASK)

in order to get

    w.connect("key_press_event", wakeup)

to work at all (but I've tested your example, and it works -- mine
doesn't, see below). There's a more explicit example here (the fact that
nobody replied made me wonder if it was just me that was confused):

  http://www.daa.com.au/pipermail/pygtk/2002-May/002757.html

While we're on the subject of key snooping, why doesn't PyGTK have a
binding to the GTK+ global key snooper, which would surely be a better
way to do all this? Is it just that nobody needed it?

-- 
Graham Ashton <[EMAIL PROTECTED]>
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to