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)
中显示了一个ValueError。x和y来自行编辑框.x和y的类型是unicode ...
我该如何添加x和y?
答案 0 :(得分:0)
def run(self):
"""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)