1

I developed a plugin in QGIS and I have attached a function on button clicked but it is calling the function two times and I don't know the reason why.

I am registering click function in plugin run event:

    def run(self):

        """Run method that performs all the real work"""
        AttachBtnClicked(self)

        # show the dialog
        self.dlg.show()
        # Run the dialog event loop
        result = self.dlg.exec_()

def AttachBtnClicked(self):
    self.dlg.btnDataSourceEncodingChangeAllLayers.clicked.connect(lambda: btnDataSourceEncodingChangeAllLayersClicked(self))

while the method is:

   def btnDataSourceEncodingChangeAllLayersClicked(self):
        print 'DataSourceEncodingChanageAllLayers : '# + encodingName
        LayerDataSourceChange()

it runs two times.

PolyGeo
  • 65,136
  • 29
  • 109
  • 338

0 Answers0