该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
from PyQt5.QtWidgets import QWidget,QApplication,QPushButton,QLabel,QLineEdit
import sys
def add():
a = line1.text()
# print(type(a))
b = line2.text()
c = int(a) + int(b)
print(c)
d = str(c)
line3.setText(d)
if __name__=='__main__':
app=QApplication(sys.argv)
#实例化对象QWidget
widget1=QWidget()
widget1.move(00,100)
widget1.resize(500,170)
#定义QLabel的显示、位置、内容
'''
label1=QLabel('请输入第一个数字:',widget1)
label1.move(30,40)
label2=QLabel('请输入第二个数字:',widget1)
label2.move(30,80)
'''
label3=QLabel('+',widget1)
label3.move(150,60)
#
line1=QLineEdit(widget1)
line1.move(140,38)
line2=QLineEdit(widget1)
line2.move(140,76)
qbtn=QPushButton('计算',widget1)
qbtn.move(100,120)
qbtn.clicked.connect(add)
line3=QLineEdit(widget1)
line3.move(180,122)
#qbtn1=QPushButton("1",widget1)
#qbtn2=QPushButton("2",widget1)
widget1.show()
widget1.setWindowTitle('加法计算器:')
sys.exit(app.exec_())