[GIS] AttributeError: ‘int’ object has no attribute ‘iface’

pyqgispythonqgis

I have assigned one method to combobox like this

def run(self):

    """Run method that performs all the real work"""
    GetAllLayers(self)
    #attach index changed event / passing parametrized method
    self.dlg.cbLayerNamesAll.currentIndexChanged.connect(lambda arg=self:  LayersValueChange(arg))

getting error here

def LayersValueChange(self):
    print "abc"
    #selectedLayerName = str(self.dlg.cbLayerNamesAll.currentText())
    #selectedLayerName = self.dlg.cbLayerNamesAll.currentText()

    layers = self.iface.legendInterface().layers()//here error

And Error is:

layers = self.iface.legendInterface().layers()
AttributeError:
'int' object has no attribute 'iface'

self is object but it getting it like int.

Best Answer

I have managed to get the answer through stackoverflow. I connecting method wrongly correct syntax is:

 self.dlg.cbLayerNamesAll.currentIndexChanged.connect(lambda: LayersValueChange(self))