Quote:
>I need to have information in my callback functions that is specific to
>the widget that called it. What information (and how can I access it) is
>passed through the 'event' parameter (especially its 'widget' attr.)
>If this information is different for different widgets, where can I find
>more information about each widget's 'Event'
Here's a summary:
char: character (empty (KeyPress, KeyRelease)
focus: focus state (Enter, Leave)
height: widget height (Configure, Expose)
keycode: the keyboard keycode (KeyPress, KeyRelease)
keysym: the keyboard keysym (KeyPress, KeyRelease)
keysym_num: the keyboard keysum, as a number (KeyPress, KeyRelease)
num: the button number (ButtonPress, ButtonRelease)
serial: a unique serial number for this event
state: additional event information (Visibility)
time: timestamp
type: event type
widget: the widget instance generating this event
width: widget width (Configure, Expose)
x: window-relative mouse x position (mouse events)
x_root: screen-relative mouse x position (mouse events)
y: window-relative mouse y position (mouse events)
y_root: screen-relative mouse y position (mouse events)
For portability reasons, you should stick to "char", "height", "width",
"x", "y", "x_root", "y_root", and "widget" unless you know exactly what
you're doing...
also see:
http://www.pythonware.com/library/tkinter/introduction/intro06.htm
Quote:
>Can I pass parameters to the callback function?
yes. the easiest way is to use lambda wrappers:
b1 = Button(master, text="One", command=lambda: click(1))
b2 = Button(master, text="Two", command=lambda: click(2))
b3 = Button(master, text="Three", command=lambda: click(3))
b1.bind("<Button-3>", lambda e: rightclick(1))
Note that to give th lambda statement access to members from your
local namespace, you need to explicitly pass them to the statement
as default arguments:
for i in range(10):
b = Button(master, text=str(i), command=lambda v=i: click(v))
b.pack()
Cheers /F
http://www.pythonware.com