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

Maciej Sieczka tutey at o2.pl
Wed Feb 6 04:28:24 EST 2008


Richard Duivenvoorde pisze:
>>> 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)

> 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)

It helped! Thank you Richard.

Maciek



More information about the Qgis-developer mailing list