嗨,在用户输入字母而不是数字时捕获实例时遇到问题。获取错误'无法为函数调用指定编号'
这是一个简单的两个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')
答案 0 :(得分:0)
错误发生在
{{param|BEC}}
信息很简单 - 您无法为电话呼叫分配号码。 (实际上,你不能为函数调用分配任何东西。)
另请注意,您可以将reply.text()= int(reply.text())
或inputMask
分配给QLineEdit,但您根本不必检查无效输入。