470,641 Members | 2,653 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,641 developers. It's quick & easy.

Where are Tkinter event.type constants defined?

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
Jun 27 '08 #1
1 1848
On May 4, 7:22*pm, Noah <n...@noah.orgwrote:
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
Hey Noah,

I recommend checking out Lundh's site (effbot) since he has lots of
information on Tkinter there. Here's his Tkinter event page:

http://effbot.org/tkinterbook/tkinte...d-bindings.htm

And there's this (less helpful):

http://docs.python.org/lib/node699.html

There's a whole chapter on events Grayson's Tkinter book, but I'm not
seeing constants defined. I think they might vary somewhat across
platforms anyway...but hopefully someone else more knowledgeable will
come along and address that.

Mike
Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Harlin Seritt | last post: by
2 posts views Thread by codecraig | last post: by
1 post views Thread by Richard Lewis | last post: by
2 posts views Thread by Fuzzyman | last post: by
3 posts views Thread by H J van Rooyen | last post: by
14 posts views Thread by Hendrik van Rooyen | last post: by
1 post views Thread by Edward K Ream | last post: by
kaarthikeyapreyan
1 post views Thread by kaarthikeyapreyan | last post: by
3 posts views Thread by skanemupp | last post: by
1 post views Thread by Korara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.