Hi,
Thank you all for you responses. With Stewart's answer I could get it
working. Those were my first lines in python (that is why I had so many
semi-colons - I'm so used to C and C++).
And also thanks for the explanation. One really needs to know how the
programming language works when writi
Hello Dídac,
just to add an explanation, why your code doesn't work:
>from Tkinter import *
>
>root = Tk();
>
>def cb(x):
>print x;
>for i in range(5):
>b = Button(root,text=i,command=lambda:cb(i));
The part "lambda:cb(i)" is a function which gets evaluated
(called) when a button is
On Feb 15, 2007, at 08:47, Dídac Busquets wrote:
> Hello,
>
> I'm trying to create a set of buttons to which I assign a callback
> that
> is the same for all of them, except for the parameter (to do this I
> use
> a lambda function). I want to get the buttons numbered from 0 to 4, so
> that w
Dídac, aquest és un problem molt interessant.
Your code doesn't work because you didn't pass in a reference to i in your
lambda. The correct code appears below. BTW, if you set up your application
with classes and methods, you will need to pass in a reference to self in
the same way: self=self.