[Qgis-developer] AttributeError: 'jacktest2Dialog' object has no attribute 'layerCombo'

jsos jack at schoenj.demon.nl
Wed May 9 17:07:55 PDT 2012


I'm quite despareate trying to extend the result of a plugin named jacktest2,
generated with the Plugin Builder.

Changed the default Ui_jacktest2.ui within the QT Creator by adding a
layerCombo object (comboBox) to the Qdialog named jacktest2. 
Saved it and recompiled this file with pyuic4. Ui_jacktest2.py was
generated.
Left jacktest2dialog.py unchanged.

Then edited jacktest2.py. 
Extending/changing the default section with the run method does generate the
changed userform but doesn't accept any code referring to the added
layerCombo object. Would like to add the visible layers to it:
    # run method that performs all the real work
    def run(self):
        dlg = jacktest2Dialog()
        dlg.show()
        # Run the dialog event loop		
        result = dlg.exec_()
        self.layerList = self.iface.mapCanvas().layers()
        self.layerCombo.clear()
        self.layerCombo.addItem("")
        for i,layer in enumerate(self.layerList):
              self.layerCombo.addItem(layer.name())
              if layer.id() == self.curLayerID:
self.layerCombo.setCurrentIndex(i+1)

        # See if OK was pressed
        if result == 1:
            # do something useful (delete the line containing pass and
            # substitute with your code)
            pass

The message is:
Traceback (most recent call last):
  File "C:/Users/Jack/.qgis/python/plugins\jacktest2\jacktest2.py", line 64,
in run
    dlg.layerCombo.clear()
AttributeError: 'jacktest2Dialog' object has no attribute 'layerCombo'

Python version:
2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]


QGIS version:
1.7.4-Wroclaw Wroclaw, 8058b22


--
View this message in context: http://osgeo-org.1560.n6.nabble.com/AttributeError-jacktest2Dialog-object-has-no-attribute-layerCombo-tp4964352.html
Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.


More information about the Qgis-developer mailing list