By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,400 Members | 903 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,400 IT Pros & Developers. It's quick & easy.

Question about Tkinter and buttons

P: 1

I wonder if I've understood this correctly

If I write my code like this

Expand|Select|Wrap|Line Numbers
  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.

Dec 4 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

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