[Qgis-developer] please help me write a QGIS-PostGIS GUI in Python

Richard Duivenvoorde rdmailings at duif.net
Tue Feb 5 17:08:51 EST 2008


>> 1. I don't know why actions tied to my GUI buttons are performed twice
>> most of the times (always?). There is sane error handling underneath

> I've seen this also in my programs that when using autoconnecting of
> slots on_*_clicked() then the function is fired twice. Now I don't
> remember what's the reason. But you can always avoid it by renaming
> the function and connecting it to a signal manually:
> self.connect(button, SIGNAL("clicked()"), function)

Hi Martin,
I've seen this too, and found something in the pyqt docs:
http://www.riverbankcomputing.com/Docs/PyQt4/pyqt4ref.html#connecting-signals-and-slots:
... without this  @pyqtSignature magic, the on_btnOk_clicked will be 
called two times, ont time for clicked() and one time for clicked(bool 
checked)

the magic is to add the signature you want to use. An example:

@pyqtSignature("on_btnBrowse_clicked()")
def on_btnBrowse_clicked(self):
     # do something
     fileName = "foo"
     self.txtFileName.setText(fileName)

Hope this is helpfull to somebody.

Regards,
Richard Duivenvoorde






More information about the Qgis-developer mailing list