Following this tutorial as a guide, I created a plugin using the Plugin Builder with the dock widget form. I am now trying to connect a pushButton
to a function. The following is a snippet of code:
def __init__(self, iface):
self.dockwidget.pushButton.clicked.connect(self.test_print)
def test_print(self):
print 'It works!'
However, I receive an:
error when calling its classFactory() method
I have also tried:
def initGui(self):
QObject.connect(self.dockwidget.pushButton, SIGNAL("clicked()"), self.test_print)
But then there's an error calling its initGui()
method. Any pointers?
Edit:
I have tried the following variations in the run(self)
function, I no longer receive errors but nothing is printed in the console:
def run(self):
#self.dockwidget.connect(self.dockwidget.pushButton,SIGNAL("clicked()"),self.test_print)
#self.dockwidget.pushButton.clicked.connect(self.test_print)
QObject.connect(self.dockwidget.ui.pushButton, SIGNAL("clicked()"), self.test_print)
Best Answer