I am trying to learn how to develop QGIS plugins but I struggle to get going by some simple principles.
As a test I am just trying to connect a function to a button. So when pressed the function run. Where to put the function and connections are not obvious to me.
This example give me an error message
TypeError: test_print() takes no arguments (2 given)
I cannot see how this give test_print 2 arguments?
def run(self): # Run test_print method when pushButton is clicked self.dlg.pushButton.clicked.connect(self.test_print) # show the dialog self.dlg.show() def test_print(): print 'It works!'
Does anyone has any general advice how to wire up buttons and functions properly?
EDIT: Working test example
def run(self): def test_print(): QMessageBox.about(None,'test','It works!') # Run test_print method when pushButton is clicked self.dlg.pushButton.clicked.connect(test_print)
Now, how can i run the test_print method if its not inside def run(self)?