def __init__(self, user_id): super().__init__() self.setupUi(self) self.show() self.user_id = user_id self.setuserinfo() self.yourlist.clear() self.comboBox.clear() self.comparison.clear() rows = DB.get_input_list(self.user_id) if rows != []: self.input_id_list = rows[:] for row in rows: self.yourlist.addItem(f'{row[0]}.{row[1]}') rows = DB.get_user_list('standard') if rows != []: self.trainer_id_list = list(zip(*rows))[0] for row in rows: self.comboBox.addItem(f'{row[1]}') # 무조건 트레이너 한명은 있다고 가정한다. rows = DB.get_math_info_list(self.trainer_id_list[0]) if rows != None: self.extraction_id_list = rows[:] for row in rows: self.comparison.addItem(f'{row[0]}.{row[1]}') self.extraction_id = 0 self.input_id = 0 self.connectFunction()
def trainer_ui(): #################################### # Basic Info # Scene No.1 트레이너 등록을 위한 UI 이다. # Console Based UI가 기본이고 INPUT에 대한 exception을 처리한다. # Feature # 유저로부터 Input을 받고 적절한 함수를 호출합니다. # Todo # 결과창 띄우기 (A+) # 비디오 분석을 건너뛰고 등록된 sample을 이용할 수 있는 옵션 추가(A) # Exercise 추가 기능 (B) # Video 조건 영어로 번역 (A) #################################### # For Print Format indent = " " * 4 # Select Exercise rows = DB.get_user_list('standard') rows.append([]) print(""" ================================================================== CHOOSE WHICH TRAINER YOU WANT TO REGISTER EXERCISE FOR""") for idx, row in enumerate(rows): if idx != len(rows) - 1: print(indent + "%d. %s" % (idx + 1, row[1])) else: print(indent + "%d. Register New Trainer" % (idx + 1, )) print(indent + """================================================================== """) option = int(input("Enter: ")) # Get PK for table of user_list trainer_id = 0 if option == len(rows): print(""" ================================================================== Register New Trainer 1. Name (English) 2. Weight (kg) 3. Stature (cm) 4. Other Info 5. Sex (men or women) ================================================================== """) # Regist New Trainer register_form = ['standard'] try: register_form.append(input("Enter Name: ")) register_form.append(int(input("Enter Weight(kg): "))) register_form.append(int(input("Enter Height(cm): "))) register_form.append(input("Enter Other Info: ")) register_form.append(input("Enter Sex: ")) if register_form[5] not in ('men', 'women', ''): raise Exception() except ValueError: print('Please enter an integer') return except Exception: print("Please enter men or women for your sex") return trainer_id = DB.create_user(*register_form) else: trainer_id = rows[option - 1][0] # Get the number of Exercise for trainer exercise_list = DB.get_exercise_list() for idx, exercise in enumerate(exercise_list): exercise_list[idx] = list(exercise) + [ len( DB.get_registered_exercise_for_one_user( trainer_id, exercise[0])) ] # Select Exercise Type print(""" ================================================================== CHOOSE WHICH EXERCISE YOU WANT TO REGISTER EXERCISE FOR""") for idx, row in enumerate(exercise_list): print(indent + "%d. %s [%d]" % (idx + 1, row[1], row[2])) print(indent + """================================================================== """) option = int(input("Enter: ")) exercise_id = exercise_list[option - 1][0] print(""" ================================================================== ENTER LOCATION OF INPUT VIDEO FILE (PLEASE CHECK VIDEO CONDITION) 1. Stand Upright Still at Least 1 Sec 2. 카메라로부터 운동하는 사람과의 거리는 해당 사람이 똑바로 서있을때와 동일해야 합니다. 3. The Maximum number of people in Video is 1 4. Cam should not Move ================================================================== """) input_video_loc = input("Enter (relative path): ") ret_val = False try: if os.path.exists(input_video_loc): ret_val = PoseSystem.regist_trainer(trainer_id, exercise_id, input_video_loc) else: raise Exception() except Exception: traceback.print_exc() return if ret_val == True: print(""" ================================================================== END OF TRAINER REGISTER PROCESS RESULT : SUCCESS ================================================================== """) else: print(""" ================================================================== END OF TRAINER REGISTER PROCESS RESULT : FAIL ================================================================== """) return