首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >量子地理信息系统

量子地理信息系统
EN

Stack Overflow用户
提问于 2016-06-14 22:10:38
回答 1查看 38关注 0票数 1
代码语言:javascript
复制
def run(self):
        """Run method that performs all the real work"""
        # show the dialog
        self.dlg.show()
        # Run the dialog event loop
        x = self.dlg.lineEdit.text()
        y = self.dlg.lineEdit_2.text()
        z = int(x)+int(y)
        result = self.dlg.exec_()
        # See if OK was pressed
            # Do something useful here - delete the line containing pass and
            # substitute with your code.
        QMessageBox.information(self.iface.mainWindow(),"sum is =", "%d" %z)

但它显示了z=int(x)+int(y).x中的ValueError,y来自x的行编辑box..type,y是unicode…我应该如何将x和y相加?

EN

回答 1

Stack Overflow用户

发布于 2016-06-20 17:56:59

定义运行(自身):

代码语言:javascript
复制
    """Run method that performs all the real work"""
    # show the dialog
    self.dlg.show()
    self.dlg.spinBox.clear()
    self.dlg.spinBox_2.clear()

    # Run the dialog event loop


    result = self.dlg.exec_()
    if result:
        x = self.dlg.spinBox.value()
        y = self.dlg.spinBox_2.value()
        z = x+y
    # See if OK was pressed
        # Do something useful here - delete the line containing pass and
        # substitute with your code.
        QMessageBox.information(self.iface.mainWindow(),"sum is =","%d" %z)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37814467

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档