2
嗨只是有一个问题捕捉实例时,用户输入一个字母,而不是数字。获取错误'不能分配数字到函数调用'pythonQt捕捉非整数输入
这是一个简单的两个QLine编辑框,用户必须猜测数字......任何帮助,将不胜感激。刚刚发布的功能位
def my_response():
global counter, random_number
timer=QtCore.QTimer
try:
reply.text()= int(reply.text())
if int(reply.text()) <self. random_number:
question.setText("Your guess is too low. Please Try Again")
reply.setText(" ")
elif int(reply.text()) >self. random_number:
question.setText("Your guess is too high. Please Try Again")
reply.setText(" ")
elif int(reply.text()) ==self. random_number:
question.setStyleSheet('QLineEdit{color: blue}')
question.setFont(QtGui.QFont("Stencil", 15, QtGui.QFont.Bold))
question.setText("Correct")
timer.singleShot(250,lambda:question.setText('You won'))
reply.setText(" ")
except:
reply.setText('invalad input number is needed')