471,325 Members | 1,491 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,325 software developers and data experts.

Question about Tkinter and buttons

Hi,

I wonder if I've understood this correctly

If I write my code like this

Expand|Select|Wrap|Line Numbers
  1.  
  2. for i in range(x):
  3.        Button(text = *, command= lambda: function(i)).grid(row=3, column=i)
If I write my code like this all the buttons get the same command, am I doing anything wrong?

Now I've created a function that creates the button for me and have the call for that function in a for i in range(x):

What I wonder really is there any better solution and I'm using Tkinter right now.

//adamsen87
Dec 4 '07 #1
0 703

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Rob | last post: by
2 posts views Thread by black | last post: by
2 posts views Thread by Paul A. Wilson | last post: by
3 posts views Thread by Sean McIlroy | last post: by
2 posts views Thread by Mulac | last post: by
6 posts views Thread by Eric_Dexter | last post: by
2 posts views Thread by skanemupp | last post: by
1 post views Thread by viv1tyagi | last post: by
3 posts views Thread by J-Burns | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.