我正在用PyQt4做测验申请,有3个主要生成器:
Incorrect
、Correct
和Timeout
所有答案都连接到计分功能:
def scorecheck(self, sendercheck):
if ( sendercheck == self.answ ) or ( sendercheck == self.answ1 ) or ( sendercheck == self.answ5 ) or ( sendercheck == self.answ7 ) or ( sendercheck == self.answ8 ) or ( sendercheck == self.answ10 ):
self.wronganswers.append(1)
elif ( sendercheck == self.answ2 ) or ( sendercheck == self.answ4 ) or ( sendercheck == self.answ9 ):
self.correctanswers.append(1)
elif sendercheck == self.tmr3:
self.timeouts.append(1)
print "Worked"
print len(self.timeouts)
else:
pass
self.wronganswerlabel = QtGui.QLabel(str(len(self.wronganswers)), self)
self.wronganswerlabel.setGeometry(220, 40, 200, 200)
self.wronganswerlabel.setObjectName('wronganswercount')
self.wronganswerlabel.setStyleSheet("#wronganswercount { font-size: 31pt; color: white; border: none; }")
self.timeoutlabel = QtGui.QLabel(str(len(self.timeouts)), self)
self.timeoutlabel.setGeometry(480, 80, 200, 200)
self.timeoutlabel.setObjectName('timeoutlabel')
self.timeoutlabel.setStyleSheet("#timeoutlabel { font-size: 31pt; color: white; border: none; }")
self.correctanswerlabel = QtGui.QLabel(str(len(self.correctanswers)), self)
self.correctanswerlabel.setGeometry(1050, 40, 200, 200)
self.correctanswerlabel.setObjectName('correctanswercount')
self.correctanswerlabel.setStyleSheet("#correctanswercount { font-size: 31pt; color: white; border: none }")
summary = len(self.correctanswers) + 100 - len(self.wronganswers) - len(self.timeouts) % 10
if summary < 0:
while summary < 0:
summary += 1
self.summarylabel = QtGui.QLabel(str(summary), self)
self.summarylabel.setGeometry(850, 222, 200, 200)
self.summarylabel.setObjectName('summary')
self.summarylabel.setStyleSheet("#summary { font-size: 40pt; color : white; border: none }")
当损失计数将达到3,它将激活gameover功能,其中将显示标签
ErrorAnswersLabel和correctanswerslabel正常显示所有内容,但timeoutlabel显示0
但是我在scorecheck和gameover函数的一般部分添加了print len(timeouts)
,所有结果都等于1
我试过这个:
self.timeouts.append(1)
self.timeouts.append(1)
奇怪的是标签上显示的是2
我还尝试了多处理记分检查功能,认为这是性能问题,但没有更新
有什么问题吗?为什么timeoutlabel显示0而其他所有的都显示正确的数字?是因为性能问题还是输入错误
我已经解决了这个问题:
功能顺序:
二 三 2 三 1 2 三 4 五
2
位于定义的标签顶部3
位于已定义标签的底部1
是超时的sendercheck语句((重要)4
位于所示标签的顶部5
显示在标签下定义计时器的位置:
通过在第一个超时信号时添加scorecheck来修复此问题:
相关问题 更多 >
编程相关推荐