# coding: gb2312 from LSZXPagesLibrary.consensus import * from LSZXPagesLibrary.pop_message_dialog import PopDialogMessage from LSZXPagesLibrary.prepare_page_layout_define import PreparePageLayoutDefine from PureBackend.global_execrise_backend import GEB class PreparePage(PreparePageLayoutDefine): def __init__(self): super(PreparePage, self).__init__() self.eb = GEB().get_geb() # 注册返回界面的按钮 self.back_home_button.clicked.connect(self.back_home) # 注册开始按钮 self.start_button.clicked.connect(self.start) # 弹窗 self.message_pop_windows = PopDialogMessage(self) self.message_pop_windows.connect(self.message_pop_commit) def refresh(self): exercise_name = EXERCISE_TYPE_TABLE[self.data[EXERCISE_TYPE]] # 判断考试类型,并激活考试 person_mes = self.data[PERSON_MES] exercise_type = self.data[EXERCISE_TYPE] band_id = person_mes[BAND_ID] person_id = person_mes[ID] if exercise_type == SIT_UP: self.eb.active_sit_up(person_id=person_id, band_id=band_id) elif exercise_type == PUSH_UP: self.eb.active_push_up(person_id=person_id, band_id=band_id) elif exercise_type == PULL_UP: self.eb.active_pull_up(person_id=person_id, band_id=band_id) elif exercise_type == HANGING: self.eb.active_overhang(person_id=person_id, band_id=band_id) elif exercise_type == RUNAROUND: self.eb.active_run_around(person_id=person_id, band_id=band_id) frame_generator = self.data[FRAME_GENERATOR] _id = person_mes[ID] _class = person_mes[CLASS] name = person_mes[NAME] self.set_title(_id, name, _class, exercise_name) self.video_displayer.set_frame_generator(frame_generator) self.video_displayer.start() def set_title(self, _id, name, _class, exercise_name): self.id_box.setText(_id) self.name_box.setText(name) self.class_box.setText(_class) self.title_label.setText(exercise_name) # 返回首页时弹窗提示 def back_home(self): self.message_pop_windows.show("此操作将结束考试, 是否继续?") # 弹窗点击了确定按钮事件 def message_pop_commit(self): # 关闭视频流 self.video_displayer.pause() # 跳转 self.jump2(HOME_PAGE) def start(self): # 开始考试 self.eb.start_exercise() # 跳转 pkg = { EXERCISE_TYPE: self.data[EXERCISE_TYPE], PERSON_MES: self.data[PERSON_MES], FRAME_GENERATOR: self.eb.get_exercise_video, PERSON_LIST: self.data.get(PERSON_LIST) } self.jump2(EXERCISE_PAGE, pkg) # 关闭视频流 self.video_displayer.pause()