[Tutor] lambda and creating GUIs

Alan Gauld alan.gauld at freenet.co.uk
Sat Jun 17 10:40:42 CEST 2006


>I understand this:
>> 
>> def f(w): gtk.main_quit()
>> button.connect("clicked", f)
>> 
> 
> Now my question is what is "w"?  What is being passed
> to the function?

That will be defined by GTk. The framework will define what 
each of its event hamdler callback functions looks like in terms 
of parameters. I don;t know GTk but going on the basis of other 
frameworkls I'll guess that its the widget where the event 
occured - a bit like self in OOP. Thus you can add the same 
handler function to several widgets and at run time manipulate 
the specific widget that was clicked or whatever.

But thats a guess based on experience - and the fact that the 
original programmer opted to call it w!

HTH,

Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld



More information about the Tutor mailing list