def name(): # window.after(0,delaytime) # # window.after(3000,f.Named) # time.sleep(3) list1, list2, _, list4, *_, surplus = f.inquire_ed() if surplus == 0 and len(list4) != 0: messagebox.showinfo( '提示', '所有学生已经点完,且尚有回答错误的同学,请开始第二轮提问,将从回答错误的列表中抽取。如需强制忽略,可从菜单》文件》重置即可') elif surplus == 0 and len(list4) == 0: messagebox.showinfo('提示', '所有学生已经点完,请备份好数据并重置') else: f.Named() list1, list2, _, list4, *_, surplus = f.inquire_ed() l_top.config(text=list2[-1]) yes_or_no(list2[-1]) l_bottom.config(text='Surplus: ' + str(surplus)) # if flag == False: list1s.set(list1) list2s.set(list2[::-1]) _list2.pack() _list1.pack() # l_top.config(text=list2[-1]) l_top.pack()
def name(): l_top.config(text = 'Click button Start random roll call') f.Named() list1,list2,counter1,counter2,surplus = f.inquire_ed() l_bottom.config(text = 'Surplus: '+str(surplus)) if flag == False: list_al.set(list1) list_ed.set(list2[::-1]) nd_list.place(x=10,y=75,anchor = 'nw') all_list.place(x=500,y=75,anchor = 'ne') l_top.config(text = list2[-1]) l_top.pack()
def name2(): _, _, list3, list4, *_ = f.inquire_ed() # print(counter1,counter2,surplus) # print(list2) if len(list4) == 0: messagebox.showinfo('Tips', '尚未没有回答错误的学生,请先开始第一轮提问!') # if bool_1 == True: # reset_nd() # else: # pass else: flag = True while flag: limite = len(list4) - 1 lucky = randint(0, limite) lucky_person = list4[lucky] # print(lucky) # print(lucky_person) ids = [row[0] for row in list3] if lucky_person[0] not in ids: list4.remove(lucky_person) flag = False os.remove(listfile4) with open(listfile4, 'w', encoding='utf-8', newline='') as lf4: writer = csv.writer(lf4) writer.writerows(list4) # list1,list2,list3,list4,counter1,counter2,surplus = f.inquire_ed() list4s.set(list4[::-1]) _list4.pack() l_top.config(text=lucky_person) yes_or_no(lucky_person) flag = False else: continue
def Uncall_person(): list1, list2, *_ = f.inquire_ed() list0 = [] for row in list1: if row in list2: continue else: list0.append(row) str0 = '还没有被点到的人 :\n' + str(list0) messagebox.showinfo('Uncall list', str0)
def Uncall_person(): list1,list2,counter1,counter2,surplus = f.inquire_ed() list0 =[] for row in list1: if row in list2: continue else: list0.append(row[1]) str0 = 'All uncalled students are :\n'+str(list0) messagebox.showinfo('Uncall list',str0)
def add_student_to_called(): Student_id = stu_id.get() nn = stu_name.get() stu_info = [Student_id,nn] list1,list2,counter1,counter2,surplus = f.inquire_ed() if stu_info not in list1: messagebox.showerror('Error', "The user isn't exist!") else: with open('Students_ed.csv', 'a',encoding = 'utf-8',newline='') as class_list: writer = csv.writer(class_list) writer.writerow(stu_info) list2.append(stu_info) list_ed.set(list2) nd_list.place(x=500,y=75,anchor = 'ne') messagebox.showinfo('Tips', 'Add seccessfully!') add_window.destroy()
def del_student_to_database(): Student_id = stu_id.get() nn = stu_name.get() stu_info = [Student_id,nn] list1,list2,counter1,counter2,surplus = f.inquire_ed() if stu_info not in list1: messagebox.showerror('Error', "The user isn't exist!") else: with open('Students.csv', 'w',encoding = 'utf-8',newline = '') as class_list: list1.remove(stu_info) writer01 = csv.writer(class_list) for row in list1: writer01.writerow(row) list_al.set(list1) all_list.place(x=500,y=75,anchor = 'ne') messagebox.showinfo('Tips', 'You have successfully delete!') add_window.destroy()
def add_student_to_database(): Student_id = stu_id.get() nn = stu_name.get() stu_info = [Student_id,nn] list1,list2,counter1,counter2,surplus = f.inquire_ed() if stu_info in list1: messagebox.showerror('Error', 'The user is already exist!') else: with open('Students.csv', 'a',encoding = 'utf-8',newline = '') as class_list: # pickle.dump(exist_usr_info, class_list) writer01 = csv.writer(class_list) writer01.writerow(stu_info) list1.append(stu_info) list_al.set(list1) all_list.place(x=500,y=75,anchor = 'ne') messagebox.showinfo('Tips', 'Add successfully!') add_window.destroy()
def del_student_to_database(): Student_id = stu_id.get() nn = stu_name.get() stu_info = [Student_id, nn] list1, list2, *_, surplus = f.inquire_ed() if stu_info not in list1: messagebox.showerror('Error', "学生信息不存在!") else: with open(listfile1, 'w', encoding='utf-8', newline='') as lf1: list1.remove(stu_info) writer01 = csv.writer(lf1) for row in list1: writer01.writerow(row) list1s.set(list1) list2s.set(list2[::-1]) _list2.pack() _list1.place() l_bottom.config(text='Surplus: ' + str(surplus - 1)) l_bottom.pack(side='bottom') messagebox.showinfo('Tips', '已成功删除!') add_window.destroy()
def add_student_to_called(): Student_id = stu_id.get() nn = stu_name.get() stu_info = [Student_id, nn] list1, list2, *_, surplus = f.inquire_ed() if stu_info not in list1: messagebox.showerror('Error', "学生信息不存在!") else: with open(listfile2, 'a', encoding='utf-8', newline='') as class_list: writer = csv.writer(class_list) writer.writerow(stu_info) list2.append(stu_info) # list1s.set(list1) list2s.set(list2[::-1]) _list2.pack() # _list1.place( ) yes_or_no(stu_info) # messagebox.showinfo('Tips', 'Add seccessfully!') l_bottom.config(text='Surplus: ' + str(surplus - 1)) l_bottom.pack(side='bottom') add_window.destroy()
def add_student_to_database(): Student_id = stu_id.get() nn = stu_name.get() stu_info = [Student_id, nn] list1, list2, *_, surplus = f.inquire_ed() if stu_info in list1: messagebox.showerror('Error', '学生信息已存在!') else: with open(listfile1, 'a', encoding='utf-8', newline='') as class_list: # pickle.dump(exist_usr_info, class_list) writer01 = csv.writer(class_list) writer01.writerow(stu_info) list1.append(stu_info) list1s.set(list1) list2s.set(list2[::-1]) _list2.pack() _list1.pack() l_bottom.config(text='Surplus: ' + str(surplus + 1)) l_bottom.pack(side='bottom') # messagebox.showinfo('Tips', 'Add successfully!') add_window.destroy()
def del_student_to_called(): Student_id = stu_id.get() nn = stu_name.get() stu_info = [Student_id, nn] _, list2, *_, surplus = f.inquire_ed() if stu_info in list2: list2.remove(stu_info) os.remove(listfile2) with open(listfile2, 'w', encoding='utf-8', newline='') as lf2: writer = csv.writer(lf2) # for row in list2: writer.writerows(list2) # list1s.set(list1) list2s.set(list2[::-1]) _list2.pack() # _list1.place() del_score(stu_info) messagebox.showinfo('Tips', '删除成功!') l_bottom.config(text='Surplus: ' + str(surplus + 1)) l_bottom.pack(side='bottom') add_window.destroy() else: messagebox.showerror('Error', "学生信息不存在!")
def print_score(): _, _, list3, *_ = f.inquire_ed() messagebox.showinfo('成绩', sorted(list3))
tabControl.add(tab1, text=' 全部学生 ') tabControl.add(tab2, text=' 已点学生 ') tabControl.pack(side='top', expand=tk.YES, fill=tk.X) tabControl2 = ttk.Notebook(page2) tab3 = ttk.Frame(tabControl2) tab4 = ttk.Frame(tabControl2) tabControl2.add(tab3, text=' 回答正确 ') tabControl2.add(tab4, text=' 回答错误 ') tabControl2.pack(side='top', expand=tk.YES, fill=tk.X) list1s = tk.StringVar() list2s = tk.StringVar() # list1.set([1,2,3,4]) # list2.set([1,2]) list1, list2, list3, list4, counter1, counter2, surplus = f.inquire_ed() list1s.set(list1) list2s.set(list2[::-1]) _list1 = tk.Listbox(tab1, listvariable=list1s) _list2 = tk.Listbox(tab2, listvariable=list2s) _list1.pack() _list2.pack() list3s = tk.StringVar() list4s = tk.StringVar() # list3.set([1,2,3,4]) # list4.set([1,2]) list3s.set(list3[::-1]) list4s.set(list4[::-1]) _list3 = tk.Listbox(tab3, listvariable=list3s)