在qpy上创建一个计算属性的插件

时间:2017-12-01 01:12:56

标签: python python-3.x python-2.7

我正在尝试创建一个qpy插件,但是我收到了一个错误。我添加的代码部分如下所示。

def run(self):
    """Run method that performs all the real work"""
    # show the dialog
    self.dlg.show()

    layers=self.iface.legendInterface().layers()
    layer_list=[]
    for layer in layers:
        layer_list.append(layer.name())

    self.dlg.comboBox.addItems(layer_list)

    # Run the dialog event loop
    result = self.dlg.exec_()
    # See if OK was pressed
    if result==1:
        # Do something useful here - delete the line containing pass and
        index=self.dlg.comboBox.currentIndex()
        layer=self.dlg.comboBox.itemData(index)
        QMessageBox.information(self.iface.mainWindow(),"Hello world","%s has %d features."%(layer.name(),layer.featureCount()))

错误:

screenshot

0 个答案:

没有答案