I have assigned one method to combobox like this

def run(self):

    """Run method that performs all the real work"""
    #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.

  • Did you use the Plugin Builder to create your plugin? If not, make sure your mainPlugin.py file contains the correct reference to iface as described here.
    – Joseph
    Oct 5, 2016 at 12:17
  • i guess there problem in registering function on currentIndexChange Oct 5, 2016 at 12:30

1 Answer 1


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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.