TKinter Event Name??
Fredrik Lundh
effbot at telia.com
Wed Mar 15 10:42:13 EST 2000
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"
}
More information about the Python-list
mailing list