[PyKDE] Lambda function call in connect statement

Aaron J. Ginn aaron.ginn at motorola.com
Thu Mar 1 17:40:55 GMT 2001

I'm trying to call a function using a lambda call with PyQt.  I bound
the function call to a button using the following commands:

        self.top_struct_button = QPushButton('Change Top     

        self.connect( self.top_struct_button, SIGNAL( "clicked()" ),
                      lambda s=self,o=ver_obj: s.changeTopStruct(o))

For debug purposes, changeTopStruct is an empty function:

    def changeTopStruct(self, drc_obj):
        Pops up an input dialog to prompt user for new top structure

Whenever I press the button, I get a segfault.  Now the function is not
doing anything, so the segfault must be occurring because of the lambda

Are lambda statements that call a function supported in PyQt?  I have to
use a lambda because I need to suppress the execution of the function
until I press the button, and I have to pass an argument to the

Am I using lambda improperly here?  Is there some special syntax I need
to use in the connect statement to use lambda?


Aaron J. Ginn                    Phone: 480-814-4463
Motorola SemiCustom Solutions    Pager: 877-586-2318
1300 N. Alma School Rd.          Fax  : 480-814-4463
Chandler, AZ 85226 M/D CH260     mailto:aaron.ginn at motorola.com

More information about the PyQt mailing list