Where are Tkinter event.type constants defined?

Noah noah at noah.org
Sun May 4 20:22:59 EDT 2008


I'm trying to match against Event.type for KeyPress and ButtonPress.
Currently I'm using integer constants (2 and 4). Are these constants
defined anywhere? The docs talk about KeyPress and ButtonPress, but I
don't see them in any of the Tkinter source files. Are these just
magic values that come out of the TK side of things and are not
defined in Python? Code like this makes me think I'm doing something
wrong:

    if event.type == 2:
        handle_key_press (event.char)
    elif event.type == 4:
        do_something_for_button ()
    else:
        pass # unknown event

(I understand that usually you would bind these function so that they
are called as a callback.)

I don't mind defining the constants myself. I just want to make sure
that I'm not missing something already done for me. Does anyone happen
to have a complete list of Event.type constants?

--
Noah



More information about the Python-list mailing list