[Tutor] lambda and creating GUIs

Christopher Spears cspears2002 at yahoo.com
Fri Jun 16 02:29:01 CEST 2006


I have been reading though the PyGTK tutorial.
Can anyone explain how lambda is being used in this
statement:

button.connect("clicked", lambda w: gtk.main_quit())

This code might put the statement in context:

# Create "Quit" button
   66	        button = gtk.Button("Quit")
   67	
   68	        # When the button is clicked, we call
the main_quit function
   69	        # and the program exits
   70	        button.connect("clicked", lambda w:
gtk.main_quit())
   71	
   72	        # Insert the quit button into the both
lower quadrants of the table
   73	        table.attach(button, 0, 2, 1, 2)
   74	
   75	        button.show()

The complete script is located at
http://www.pygtk.org/pygtk2tutorial/sec-TablePackingExample.html.




More information about the Tutor mailing list