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相加?
发布于 2016-06-20 17:56:59
定义运行(自身):
"""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)https://stackoverflow.com/questions/37814467
复制相似问题