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')