I'm having a problem using lambda to use a command with an argument for a button in Tkinter.
buttons = range(5) for x in xrange(5): buttons[x] = Button(frame, text=str(x+1), command=lambda: self.highlight(x)) buttons[x].pack(side=LEFT) The buttons are correctly numbered 1 through 5, but no matter which button I click on, it sends the number 4 as an argument to the highlight function. How can I correct this? By the way, I've tried changing xrange to range with no success. -- http://mail.python.org/mailman/listinfo/python-list