def DeleteFram(self): print("九九乘法表 DeleteFram Start") global sec,VideoThreadEnd,StopFlag # 设置退出标志为True self.EndFlag = True # 手势识别非正常结束 VideoThreadEnd = False # 初始化按钮标志 self.ButtonFlag = True self.right_button_1.setText("确定") print("九九乘法表 VideoSingleton.timer.disconnect(self.GetTimeVideoResult)") VideoSingleton.timer.disconnect(self.GetTimeVideoResult) print("九九乘法表 设置结束标志") # 定时器结束标志 StopFlag = True # 手势识别定时器结束标志 VideoSingleton.SetShowFlag(False) self.timevideothread.SetVideoSingleton(True) self.right_bottom_label_1.setPixmap(QPixmap("../images/空.png")) # self.ChangeNumberTime(self.right_top_label_1, self.right_top_label_2, int(sec/10), int(sec%10)) print("九九乘法表 DeleteFram End")
def GetAnswer(self): self.Arrow_indication(0, False) self.Arrow_indication(1, False) self.Arrow_indication(2, False) self.Arrow_indication(3, False) self.GetAnswerFlag = True self.timevideothread.SetVideoSingleton(True) VideoSingleton.SetShowFlag(False) QmutNN.lock() self.right_Number_LineEdit_5.setText("查看答案") self.right_Number_LineEdit_6.setText("正确答案如下") self.right_bottom_label_1.setPixmap(QPixmap("../images/对号.png")) self.right_bottom_label_1.setScaledContents(True) # 让图片自适应label大小 if self.Randomindex == 1: cur = self.rightvalue if cur <= 9: self.ChangeNumberImage(self.right_Number_LineEdit_3, 3, self.firstrightvalue) # self.ChangeNumberImage(self.right_Number_LineEdit_4, 4, self.secondrightvalue) else: self.ChangeNumberImage(self.right_Number_LineEdit_3, 3, self.firstrightvalue) self.ChangeNumberImage(self.right_Number_LineEdit_4, 4, self.secondrightvalue) else: self.ChangeNumberImage(self.right_Number_LineEdit_1, 1, self.firstleftvalue) self.ChangeNumberImage(self.right_Number_LineEdit_2, 2, self.secondleftvalue) QmutNN.unlock()
def WriteTrueValue(self): VideoSingleton.SetShowFlag(False) self.right_Number_LineEdit_5.setText("手势识别多次输入错误,请检查下手势的正确性以及周围环境") self.right_Number_LineEdit_6.setText("正确答案如下") if self.Randomindex == 1: cur = self.rightvalue if cur <= 9: self.ChangeNumberImage(self.right_Number_LineEdit_3, 3, self.firstrightvalue) # self.ChangeNumberImage(self.right_Number_LineEdit_4, 4, self.secondrightvalue) else: self.ChangeNumberImage(self.right_Number_LineEdit_3, 3, self.firstrightvalue) self.ChangeNumberImage(self.right_Number_LineEdit_4, 4, self.secondrightvalue) else: self.ChangeNumberImage(self.right_Number_LineEdit_1, 1, self.firstleftvalue) self.ChangeNumberImage(self.right_Number_LineEdit_2, 2, self.secondleftvalue)
def NN_Table_Start(self): if self.VideoFlag: self.right_button_4.setHidden(False) self.show_Arrow() self.right_button_1.setEnabled(False) VideoSingleton.SetShowFlag(True) self.videothread.SetVideoSingleton(False) self.videothread.start() # 设置提示语 self.right_Number_LineEdit_5.setText( "根据箭头所指空格摆出手势,使得等式成立(可能有多种答案)") self.right_Number_LineEdit_6.setText("") else: self.timerthread.start() self.right_button_4.setHidden(True)
def end(self): global StopFlag,sec,VideoThreadEnd if self.IsTrue(): self.right_bottom_label_1.setPixmap(QPixmap("../images/对号.png")) self.right_bottom_label_1.setScaledContents(True) # 让图片自适应label大小 else: Button_timeout.lock() if self.Button_timeout_flag: return self.Button_timeout_flag = True self.right_bottom_label_1.setPixmap(QPixmap("../images/错号.png")) self.right_bottom_label_1.setScaledContents(True) # 让图片自适应label大小 # 结束定时器 StopFlag = True # 开启手势识别 VideoSingleton.SetShowFlag(True) # 提示语 self.GetTipsValue() # 设置按钮可见 self.right_button_3.setHidden(False) # 设置手势识别定时器秒数 sec = 12 # 填写错误之后将全部编辑框锁定 self.right_Number_LineEdit_1.setReadOnly(False) self.right_Number_LineEdit_2.setReadOnly(False) self.right_Number_LineEdit_3.setReadOnly(False) self.right_Number_LineEdit_4.setReadOnly(False) # 获得编辑框列表需要手势识别的下标 self.Changelst = copy.deepcopy(self.lst) self.show_Arrow() VideoThreadEnd = False print("九九乘法表 QLineEditCount ", QLineEditCount) self.timevideothread.start() Button_timeout.unlock() self.right_button_1.setText("下一题") self.ButtonFlag = False
def InputAgain(self): global sec self.videothread.SetVideoSingleton(True) QmutNN.lock() if self.VideoFlag: sec = self.Timing self.Changelst = copy.deepcopy(self.lst) self.GetArrayLineEditRead() self.show_Arrow() self.right_button_1.setEnabled(False) VideoSingleton.SetShowFlag(True) self.videothread.SetVideoSingleton(False) self.videothread.start() # 设置提示语 self.right_Number_LineEdit_5.setText( "根据箭头所指空格摆出手势,使得等式成立(可能有多种答案)") self.right_Number_LineEdit_6.setText("") self.InitInput() QmutNN.unlock() return
def DeleteFram(self): print("九九乘法表 DeleteFram Start") global sec, VideoThreadEnd, StopFlag # 恢复答题流程标志 self.ChangeAnswerFlag = False # 设置退出标志为True self.EndFlag = True # 手势识别非正常结束 VideoThreadEnd = False # 初始化按钮标志 self.ButtonFlag = True self.right_button_1.setText("确定") # 清除箭头 self.gifnoshow() print("九九乘法表 设置结束标志") VideoSingleton.timer.disconnect(self.GetTimeVideoResult) # 定时器结束标志 if self.VideoFlag: self.videothread.SetVideoSingleton(True) else: StopFlag = True # 手势识别定时器结束标志 VideoSingleton.SetShowFlag(False) self.timevideothread.SetVideoSingleton(True) self.right_bottom_label_1.setPixmap(QPixmap("../images/空.png")) print("九九乘法表 DeleteFram End")
def ChangeButtonStatus(self): global StopFlag,sec,VideoThreadEnd,QLineEditCount print("九九乘法表 ChangeButtonStatus") # 确定 if self.ButtonFlag == True: print("九九乘法表 self.ButtonFlag True") self.right_button_1.setEnabled(False) self.right_button_2.setEnabled(False) StopFlag = True QmutNN.lock() if self.IsTrue(): self.right_Number_LineEdit_5.setText("恭喜你,回答正确") self.right_Number_LineEdit_6.setText("") print("九九乘法表 self.ButtonFlag True self.IsTrue() True") self.right_bottom_label_1.setPixmap(QPixmap("../images/对号.png")) self.right_bottom_label_1.setScaledContents(True) # 让图片自适应label大小 else: print("九九乘法表 self.ButtonFlag True self.IsTrue() False") Button_timeout.lock() if self.Button_timeout_flag: Button_timeout.unlock() QmutNN.unlock() return self.Button_timeout_flag = True self.right_bottom_label_1.setPixmap(QPixmap("../images/错号.png")) self.right_bottom_label_1.setScaledContents(True) # 让图片自适应label大小 # 开启手势识别 VideoSingleton.SetShowFlag(True) # 设置定时器秒数 sec = 12 # 提示语 self.GetTipsValue() # 设置按钮可见 self.right_button_3.setHidden(False) self.right_button_3.setEnabled(True) # 填写错误之后将全部编辑框锁定 self.right_Number_LineEdit_1.setReadOnly(True) self.right_Number_LineEdit_2.setReadOnly(True) self.right_Number_LineEdit_3.setReadOnly(True) self.right_Number_LineEdit_4.setReadOnly(True) # 获得编辑框列表需要手势识别的下标 self.Changelst = copy.deepcopy(self.lst) VideoThreadEnd = False # 显示箭头 self.show_Arrow() # print("QLineEditCount ",QLineEditCount) self.timevideothread.start() Button_timeout.unlock() self.right_button_1.setText("下一题") self.ButtonFlag = False QmutNN.unlock() # 下一题 else: print("九九乘法表 self.ButtonFlag False") if self.IsTrue(): print("九九乘法表 self.IsTrue() True") self.NN_Start() self.right_bottom_label_1.setPixmap(QPixmap("../images/空.png")) self.right_button_1.setText("确定") self.ButtonFlag = True return if VideoThreadEnd: print("九九乘法表 VideoThreadEnd 正常结束") VideoThreadEnd = False self.NN_Start() self.right_bottom_label_1.setPixmap(QPixmap("../images/空.png")) self.right_button_1.setText("确定") else: self.timevideothread.SetVideoSingleton(True) QmutNN.lock() print("九九乘法表 No VideoThreadEnd 中断结束") self.right_button_1.setEnabled(False) self.right_button_2.setEnabled(False) self.right_button_3.setEnabled(False) VideoSingleton.SetShowFlag(False) QmutNN.unlock() VideoSingleton.SetShowFlag(False) self.ButtonFlag = True
def GetTimeVideoResult(self, result): # 语音提醒 MusicSingleton.start() self.index = -1 self.indexflag = True global QLineEditCount, VideoThreadEnd # print(self.Changelst) for i in range(0, len(self.Changelst)): if self.Changelst[i] == True: self.Changelst[i] = False self.index = i break self.show_Arrow() if self.index == 0: self.ChangeNumberImage(self.right_Number_LineEdit_1, 1, result) elif self.index == 1: self.ChangeNumberImage(self.right_Number_LineEdit_2, 2, result) elif self.index == 2: self.ChangeNumberImage(self.right_Number_LineEdit_3, 3, result) elif self.index == 3: self.ChangeNumberImage(self.right_Number_LineEdit_4, 4, result) for i in range(self.index, len(self.Changelst)): if self.Changelst[i] == True: self.indexflag = False if self.VideoFlag & (self.ChangeAnswerFlag == False): print("self.ChangeAnswerFlag", self.ChangeAnswerFlag) print("手势回答") if self.indexflag: VideoSingleton.SetShowFlag(False) self.right_button_1.setEnabled(True) return print("九九乘法表 GetTimeVideoResult self.index", self.indexflag) if self.indexflag == True: if self.IsTrue() == False: if self.ErrorCount == 1: # 写入正确答案 self.WriteTrueValue() self.right_bottom_label_1.setPixmap( QPixmap("../images/对号.png")) self.ErrorCount = 0 else: self.ErrorCount += 1 print("九九乘法表 回答错误,重新根据提示摆出酷酷的手势") self.GetTipsValueFirst() # self.right_Number_LineEdit_5.setText("回答错误,重新根据提示摆出酷酷的手势") self.Changelst = copy.deepcopy(self.lst) self.show_Arrow() print("九九乘法表 GetTimeVideoResult self.Changelst", self.Changelst) print("九九乘法表 GetTimeVideoResult self.lst", self.lst) QmutNN.lock() VideoThreadEnd = False QLineEditCount = self.LineEditCount QmutNN.unlock() print("九九乘法表 QLineEdit", QLineEditCount) print("九九乘法表 VideoThreadEnd", VideoThreadEnd) print("九九乘法表 self.timevideothread.start()") self.timevideothread.start() else: self.right_Number_LineEdit_5.setText("恭喜你,回答正确") self.right_Number_LineEdit_6.setText("") self.right_bottom_label_1.setPixmap( QPixmap("../images/对号.png")) self.right_bottom_label_1.setScaledContents( True) # 让图片自适应label大小 else: self.GetTipsValueSecond() return
# 结束首页动画,展示主页面 def HomePage(window,main_window): window.close() main_window.show() if __name__ == "__main__": print("start") app = QApplication(sys.argv) print("init QApplication,ui") window = Main_ui() AbWindow = AbnormityWindow() AbWindow.show() # window.show() # window.move(300,300) print("window.x()", window.x()) print("window.y()", window.y()) # 开始摄像头 VideoSingleton.start() VideoSingleton.SetShowFlag(False) workthread = HomeWorkThread() workthread.timer.connect(lambda:HomePage(AbWindow,window)) workthread.start() print("end while") sys.exit(app.exec_())