Subject: Re: TKinter Event Name?? - DN [1]
"Fredrik Lundh" <effbot@telia.com> - 15 Mar 2000 - comp.lang.python
Matthias Barmeier wrote:
> does anybody know how to retrieve the event name
> in an event callback ?
event.type contains a numeric code (passed to the
callback as a string). the attached dictionary maps
back from int(event.type) to the event name.
however, it's probably better to use one binding per
event type you need to handle, with distinct callbacks
and/or lambdas:
widget.bind("<Any-Button>", lambda e, cb=callback: cb(e, "button"))
widget.bind("<Any-Key>", lambda e, cb=callback: cb(e, "key"))
</F>
event_map = {
2: "KeyPress",
3: "KeyRelease",
4: "ButtonPress",
5: "ButtonRelease",
6: "MotionNotify",
7: "EnterNotify",
8: "LeaveNotify",
9: "FocusIn",
10: "FocusOut",
11: "KeymapNotify",
12: "Expose",
13: "GraphicsExpose",
14: "NoExpose",
15: "VisibilityNotify",
16: "CreateNotify",
17: "DestroyNotify",
18: "UnmapNotify",
19: "MapNotify",
20: "MapRequest",
21: "ReparentNotify",
22: "ConfigureNotify",
23: "ConfigureRequest",
24: "GravityNotify",
25: "ResizeRequest",
26: "CirculateNotify",
27: "CirculateRequest",
28: "PropertyNotify",
29: "SelectionClear",
30: "SelectionRequest",
31: "SelectionNotify",
32: "ColormapNotify",
33: "ClientMessage",
34: "MappingNotify"
}
Last modified
2000-07-20
2000-07-20
(195.108.246.52)
Note: you are looking at
the snapshot of an old wiki
- much of this information
is likely to be very outdated
