Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Where are Tkinter event.type constants defined?

Reply
Thread Tools

Where are Tkinter event.type constants defined?

 
 
Noah
Guest
Posts: n/a
 
      05-05-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
 
Reply With Quote
 
 
 
 
Mike Driscoll
Guest
Posts: n/a
 
      05-05-2008
On May 4, 7:22*pm, Noah <(E-Mail Removed)> wrote:
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: What is the differences between tkinter in windows and Tkinter inthe other platform? Hidekazu IWAKI Python 0 12-15-2009 05:58 AM
What is the differences between tkinter in windows and Tkinter in theother platform? Hidekazu IWAKI Python 1 12-14-2009 03:44 PM
from Tkinter import *,win = Tk() "from Tkinter import *" Pierre Dagenais Python 0 08-03-2008 10:33 PM
Re: [Tkinter-discuss] Please help -- Tkinter Scale widget withDoubleVar is acting weird Jeff Epler Python 0 08-23-2004 02:31 PM
Re: [Tkinter-discuss] Please help -- Tkinter Scale widget withDoubleVar is acting weird Jeff Epler Python 0 08-20-2004 12:07 PM



Advertisments