I have seen several solutions for passing additional arguments to a Tkinter event handler that use wrapper functions in different ways. But for a simple case of passing some extra static data in the event is there any drawback to doing it this way:

widget.my\_private\_attribute = my\_private\_data

and recovering the data from the event in the event handler:

private\_data = event.widget.my\_private\_attribute

I've tried it and it works, but it doesn't appear in any of the suggested solutions I've seen so I'm concerned there's some drawback I'm not aware of.

Here is a code sample. Re the comment on the meaning of "private" I guess that was misleading. I meant "made up by me, not one of the standard tk attributes".

```
:
:
def onClickPosition(event):
    print "you clicked on", event.widget.grid_position
    if event.widget.cget("bg") == "red":
        event.widget.config(bg="yellow")
    else:
        event.widget.config(bg="red")

root = tk.Tk()

buttonList = []

for i in range(16):
    for j in range(16):
        square = tk.PhotoImage(file="small_square_30x30pix.gif")
        l = tk.Label(root, image=square, borderwidth=0, bg="yellow")
        l.save_image = square
        l.grid_position=(i,j)
        l.bind("<1>", onClickPosition)
        l.grid(row=i, column=j)
        buttonList.append(l)
:
:

```

"grid\_position" is the data I an referring to.

I've seen several variations on the solution at:

<http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/extra-args.html>

But the way I'm doing it seems simpler.