The following code demonstrates how callback functions for all functions of a module are created.
for funcName in dir( pysp.examples.exampleCode): if funcName.find( 'example') != 0: continue action = QtGui.QAction( funcName[7:], self) action.triggered.connect( self.make_example( funcName)) self.examplesMenu.addAction( action) def make_example( self, funcName): def func(): f = getattr( pysp.examples.exampleCode, funcName) if callable( f): f() else: print( "pySpectraGuiClass.make_example: problem with %s" % funcName) return return func