Hi Guido,

> Is it possible to have a set of buttons, all calling to the same function, 
> recognize which of the buttons was the one that call the function?

 One solution to your problem, using lambda to define the function call.

from Tkinter import *

def killBut(but):
    but.pack_forget()

tk = Tk()

but1=Button(tk, text="B1")
but1['command']=lambda b=but1: killBut(b)
but1.pack(side=LEFT)

but2=Button(tk, text="B2")
but2['command']=lambda b=but2: killBut(b)
but2.pack(side=LEFT)

tk.mainloop()



On Sun, Aug 15, 2010 at 4:06 AM, Guido Carballo-Guerrero <char...@me.com> wrote:
> Hello;
>

>
> 'Cause what I want to do, is create a set of buttons, where I will not know 
> how many buttons will be created, that will depend on the input of the user. 
> Once the user have this, he will click one of those buttons, and depending on 
> which button was press, the program will erase that part of the input that 
> the operator gave.
>
> Regards!
>
> Guido Carballo
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss@python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss
>
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to