[Tkinter-discuss] writing a function to create button
Michael Lange
klappnase at web.de
Fri May 5 11:42:08 CEST 2006
On Fri, 5 May 2006 11:04:20 +0300
"Ilknur Ozturk" <Ilknur.Ozturk at cabot.com.tr> wrote:
> Hi all,
>
>
>
> I prepared a GUI which contains lots of buttons. Instead of defining
> each of them one by one, I want to write a function that gets the
> parameters and create a button.(Each one calls same function for
> buttonclick event) Is it possible? If it is, can you give me a simple
> example?
>
Hi Ilknur,
maybe you mean something like
buttons = []
r = 0
c = 0
for i in range(100):
b = Button(master, text=i, **kw)
b.grid(row=r, column=c)
buttons.append(b)
c += 1
if c > 10:
c = 0
r += 1
I hope this helps
Michael
More information about the Tkinter-discuss
mailing list