Error in Python plugin
I'm following a tutorial for developing a plugin for gqis, but I'm stuck
in a error, when trying to insert a text in a textbox window. The code is
as demonstrated here
Class vector_selectbypointdialog.py:
from PyQt4 import QtCore, QtGui
from ui_vector_selectbypoint import Ui_vector_selectbypoint
# create the dialog for zoom to point
class vector_selectbypointDialog(QtGui.QDialog):
def __init__(self):
QtGui.QDialog.__init__(self)
# Set up the user interface from Designer.
self.ui = Ui_vector_selectbypoint()
self.ui.setupUi(self)
def setTextBrowser(self, output):
self.ui.txtFeedback.setText(output)
def clearTextBrowser(self):
self.ui.txtFeedback.clear()
Class vector_selectbypoint.py:
under init create the object like this:
# create our GUI dialog
self.dlg = vector_selectbypointDialog()
And the method that handles to insert the text:
handleMouseDown(self, point, button):
self.dlg.clearTextBrowser()
self.dlg.setTextBrowser( str(point.x()) + " , " +str(point.y()) )
The error is:
handleMouseDown self.dlg.clearTextBrowser() AttributeError:
'vector_selectbypointdialog' object has no attribute 'clearTextBrowser'
This tuto doesn't seem to work...
ReplyDeleteActually, I've just gone through the tutorial and the errors myself and found the solution was to do the following:
ReplyDeleteIn vector_selectbypointdialog.py in the def __init__(self,iface) function you should have the following lines:
QtGui.QDialog.__init__(self)
self.ui = Ui_vector_selectbypoint()
self.ui.setupUi(self)
That last line was the problem for me. In the tutorial, it was written as:
self.setupUi(self)
which turned out to be wrong. I hope this helps and you're able to get through the tutorial. I'm still working on it, but at least it is working thus far and actually printing to the txtBrowser in the dialog!!