Python实现数学答题器(附源码)

这是一个数学答题器,它可以实现在线做题,生成试卷并导出,历史记录,保存错题等功能

运行出来的窗口大致如下图所示:

完整代码:

向大家请教一个问题:在上图中有三个‘下一题’,分别代表着不同的功能,我如何把他们集合在一起?

import tkinter as tk
import tkinter.messagebox
import random
import secrets
import pyperclip
import datetime

window = tk.Tk()
window.geometry("350x295")
window.title("数学答题器")

answer = tk.StringVar()
operation_list = ["+", "-", "*", "/"]
op_list = ["+"]
choose = secrets.choice(operation_list)
low_limit = tk.IntVar()
height_limit = tk.IntVar()
on_hit = False
on_hit2 = False
on_hit3 = True
def practice():
    global on_hit
    on_hit = True
    question_label.config(text="")
    answer.set("")
    with open("C:\\Users\\admin\\Deskto\\错题本.txt", "r", encoding='utf-8') as file:
        try:
            practice_list = [file.read()]
            new_list = []
            for question_join in practice_list:
                question_join_line = question_join.splitlines()
                while "" in question_join_line:
                    question_join_line.remove("")
                print(question_join_line)
                for string in question_join_line:
                    new_string = string.split("=")[0]
                    new_list.append(new_string)
                print(new_list)
                choice = random.choice(new_list)
                question_label.config(text=f"{choice}")
                listbox.delete("1.0", tk.END)
        except IndexError:
                tkinter.messagebox.showwarning(title="提示", message="你还没有错题哦~点击确定转换为普通模式")
                question_label.config(text=f"{random.randint(int(low_limit.get()), int(height_limit.get()))} {secrets.choice(op_list)} {random.randint(int(low_limit.get()), int(height_limit.get()))}")
def next():
    global choose2
    choose2 = secrets.choice(op_list)
    user_answer = answer_Entry.get()
    question_text = question_label.cget("text")
    try:
        print(operation_list)
        print(low_limit)
        print(height_limit)
        if eval(user_answer) == eval(question_text):
            true_or_false.config(bg="green")
            true_or_false.config(text="正确")
            true_number_get = true_number.cget("text")
            true_number.config(text=f"{int(true_number_get) + 1}")
            total_number_get = total_number.cget("text")
            total_number.config(text=f"{int(total_number_get) + 1}")
            with open("C:\\Users\\admin\\Desktop\\历史记录.txt", "a") as f:
                f.write(f"{question_text} = {eval(question_text)} 你的答案:{answer.get()}\n")
            answer.set("")
            random_1 = random.randint(int(low_limit.get()),int(height_limit.get()))
            random_2 = random.randint(int(low_limit.get()), int(height_limit.get()))
            question_label.config(text=f"{random_1} {choose2} {random_2}  ")
            if random_1 < random_2 and choose2 == "-":
                random_1 = random.randint(int(low_limit.get()),int(height_limit.get()))
                random_2 = random.randint(int(low_limit.get()), int(height_limit.get()))
                question_label.config(text=f"{random_1} {choose2} {random_2}  ")
        else:
            true_or_false.config(bg="red")
            true_or_false.config(text=f'错误  {question_text} = {eval(question_text)}')
            false_number.config(text=f"{int(false_number.cget('text')) + 1}")
            total_number_get = total_number.cget("text")
            total_number.config(text=f"{int(total_number_get) + 1}")
            false_answer = f"{question_text} = {eval(question_text)}"
            listbox.insert("end", chars=f"{false_answer}\n")
            with open("C:\\Users\\admin\\Desktop\\历史记录.txt", "a") as f:
                f.write(f"{false_answer} 你的答案:{answer.get()}\n")
            answer.set("")
            random_1 = random.randint(int(low_limit.get()),int(height_limit.get()))
            random_2 = random.randint(int(low_limit.get()), int(height_limit.get()))
            question_label.config(text=f"{random_1} {choose2} {random_2}  ")
            if random_1 < random_2 and choose2 == "-":
                random_1 = random.randint(int(low_limit.get()),int(height_limit.get()))
                random_2 = random.randint(int(low_limit.get()), int(height_limit.get()))
                question_label.config(text=f"{random_1} {choose2} {random_2}  ")
    except (ValueError,SyntaxError,NameError,ZeroDivisionError):
        true_or_false.config(text="输入值错误")
        true_or_false.config(bg="red")
        false_number.config(text=f"{int(false_number.cget('text')) + 1}")
        total_number_get = total_number.cget("text")
        total_number.config(text=f"{int(total_number_get) + 1}")
        false_answer = f"{question_text} = {eval(question_text)}"
        listbox.insert("end", chars=f"{false_answer}\n")
        with open("C:\\Users\\admin\\Desktop\\历史记录.txt", "a") as f:
            f.write(f"{question_label.cget('text')} = {eval(question_label.cget('text'))} 你的答案:{answer.get()}\n")
        answer.set("")
        random_1 = random.randint(int(low_limit.get()),int(height_limit.get()))
        random_2 = random.randint(int(low_limit.get()), int(height_limit.get()))
        question_label.config(text=f"{random_1} {choose2} {random_2}  ")
        if random_1 < random_2 and choose2 == "-":
            random_1 = random.randint(int(low_limit.get()),int(height_limit.get()))
            random_2 = random.randint(int(low_limit.get()), int(height_limit.get()))
            question_label.config(text=f"{random_1} {choose2} {random_2}  ")
    except tkinter.TclError:
        tkinter.messagebox.showerror(message="上下限请设置为数字")
def again():
    choose2 = secrets.choice(op_list)
    true_number.config(text="0")
    false_number.config(text="0")
    total_number.config(text="0")
    random_1 = random.randint(int(low_limit.get()),int(height_limit.get()))
    random_2 = random.randint(int(low_limit.get()), int(height_limit.get()))
    question_label.config(text=f"{random_1} {choose2} {random_2}  ")
    if random_1 < random_2 and choose2 == "-":
        random_1 = random.randint(int(low_limit.get()),int(height_limit.get()))
        random_2 = random.randint(int(low_limit.get()), int(height_limit.get()))
        question_label.config(text=f"{random_1} {choose2} {random_2}  ")
def paper_maker():
    paper_maker_window = tk.Toplevel(window)
    paper_maker_window.geometry("200x100")
    paper_maker_window.title("试卷生成器")

    question_number_var = tk.StringVar()
    height_limit_var = tk.IntVar()
    low_limit_var = tk.IntVar()
    def paper_generate():
        def copy():
            copy_question = text.get("1.0", "end")
            pyperclip.copy(copy_question)
            tkinter.messagebox.showinfo(message="已复制")
        def txt():
            with open("C:\\Users\\admin\\Desktop\\数学试卷.txt", "a") as f:
                f.write(f"""
{datetime.datetime.now()}
{str(text.get("1.0", "end"))}""")
            tkinter.messagebox.showinfo(message="文件导入成功")
        def clear():
            flie = open("C:\\Users\\admin\\decktop\\数学试卷.txt", "r+")
            flie.truncate(0)
            flie.close()
            tkinter.messagebox.showinfo(message="试卷已清空")
        def again_and():
            text.delete("1.0", tk.END)
            paper_window.destroy()
        def view_pa():
            view_window = tk.Toplevel(window)
            view_window.geometry("200x300")
            view_window.title("试卷查看器")

            view_text = tk.Text(view_window, width=26, height=20)
            view_text.pack()
            try:
                with open("C:\\Users\\admin\\Desktop\\数学试卷.txt", "r") as f:
                    read = f.read()
                    view_text.insert("end", chars=f"{read}")
            except FileNotFoundError:
                tkinter.messagebox.showerror(view_window,message="你还没有试卷文件哦~")
        paper_window = tk.Toplevel(window)
        paper_window.geometry("325x250")
        paper_window.title("试卷")
        text = tk.Text(paper_window, height=18, width=20)
        text.place(x=0, y=0)
        copy_button = tk.Button(paper_window, text="复制", width=20, height=1, command=copy)
        copy_button.place(x=150, y=0)
        txt_button = tk.Button(paper_window, text="导入 数学试卷.txt", width=20, height=1,command=txt)
        txt_button.place(x=150, y=40)
        txt_label = tk.Label(paper_window, text="""
    文件名数学试卷
    admin文件夹中
        """)
        txt_label.place(x=150, y=70)
        clear_txt = tk.Button(paper_window, text="清空试卷文件", width=20, height=1, command=clear)
        clear_txt.place(x=150, y=140)
        agin_and_again = tk.Button(paper_window, text="再来一些", width=20, height=1,command=again_and)
        agin_and_again.place(x=150, y=175)
        view_paper = tk.Button(paper_window, text="查看所有试卷", width=20, height=1, command=view_pa)
        view_paper.place(x=150, y=220)
        try:
            if int(question_number_var.get()) != 0:
                for i in range(int(question_number_var.get())):
                    question = f"{random.randint(int(height_limit_var.get()), int(low_limit_var.get()))} {random.choice(op_list)} {random.randint(int(height_limit_var.get()), int(low_limit_var.get()))}"
                    if question in text.get("1.0", "end"):
                        question = f"{random.randint(int(height_limit_var.get()), int(low_limit_var.get()))} {random.choice(op_list)} {random.randint(int(height_limit_var.get()), int(low_limit_var.get()))}"
            else:
                text.insert("end", chars="")
        except ValueError:
            paper_window.destroy()
            tkinter.messagebox.showerror(message="请输入数字!")
        paper_window.mainloop()
    question_number = tk.Label(paper_maker_window, text="题目数量")
    question_number.place(x=0,y=0)
    question_number_entry = tk.Entry(paper_maker_window, textvariable=question_number_var, width=10)
    question_number_entry.place(x=60,y=0)
    limit = tk.Label(paper_maker_window, text="取值范围")
    limit.place(x=0,y=25)
    limit_height = tk.Entry(paper_maker_window, width=3, textvariable=height_limit_var)
    limit_height.place(x=60, y=25)
    to = tk.Label(paper_maker_window, text="~")
    to.place(x=80, y=25)
    limit_low = tk.Entry(paper_maker_window, width=3, textvariable=low_limit_var)
    limit_low.place(x=95, y=25)
    ok_button = tk.Button(paper_maker_window, text="OK", width=20, height=1, command=paper_generate)
    ok_button.place(x=0,y=58) 
    paper_maker_window.mainloop()
def cuoti():
    with open("C:\\Users\\admin\\Desktop\\错题本.txt", "a", encoding="ANSI" and "gbk" and "utf-8") as f:
        f.write(f"""
{listbox.get("1.0", "end")}
""")
def reset_ctb():
    file = open("C:\\Users\\admin\\Desktop\\错题本.txt", "r+")
    file.truncate(0)
    file.close()
def reset_ctj():
    listbox.delete("1.0", tk.END)
def v_cuoti():
    cuoti_window = tk.Toplevel(window)
    cuoti_window.geometry("200x300")
    cuoti_window.title("错题本")

    cuoti_text = tk.Text(cuoti_window, width=27, height=22)
    cuoti_text.place(x=0, y=0)

    with open("C:\\Users\\admin\\Desktop\\错题本.txt", "r") as f:
        cuoti_text.insert("end", chars=f"""
{f.read()}""")
    
def history_record():
    search_var = tk.StringVar()
    history_window = tk.Toplevel(window)
    history_window.geometry("470x320")
    history_window.title("历史记录")

    def clear_history():
        history_text.delete("1.0", tk.END)
        history_file = open("C:\\Users\\admin\\Desktop\\历史记录.txt", "r+")
        history_file.truncate(0)
        history_file.close()
    def close():
        history_window.destroy()
    def search():
        search_text.delete("1.0", tk.END)
        with open("C:\\Users\\admin\\Desktop\\历史记录.txt", "r") as file:
            keyword = search_entry.get()
            lines = file.readlines()
            keyword_lines = [line for line in lines if keyword in line]
            string = "\n".join(keyword_lines)
            search_text.insert("end", chars=f"{string}\n")
        if string == "":
            search_text.insert("end", chars="无搜索结果.\n")
        else:
            pass
    def search_clear_s():
        search_var.set("")
        search_text.delete("1.0", tk.END)
    history_text = tk.Text(history_window, height=20,width=35)
    history_text.place(x=0, y=0)
    clear_button = tk.Button(history_window, width=15, height=1, text="清空历史", command=clear_history)
    clear_button.place(x=0, y=270)
    close_button = tk.Button(history_window, width=15, height=1, text="关闭", command=close)
    close_button.place(x=130, y=270)
    search_entry = tk.Entry(history_window, width=20, textvariable=search_var)
    search_entry.place(x=250, y=0)
    search_button = tk.Button(history_window, width=8, height=1, text="搜索", command=search)
    search_button.place(x=380, y=0)
    search_text = tk.Text(history_window, width=30, height=18)
    search_text.place(x=250, y=30)
    search_clear = tk.Button(history_window, width=20, height=1, text="清空", command=search_clear_s)
    search_clear.place(x=250, y=270)
    with open("C:\\Users\\admin\\Desktop\\历史记录.txt", "r") as f:
        history_text.insert("end", chars=f"{f.read()}")
    
def settings():
    setting_window = tk.Toplevel(window)
    setting_window.geometry("220x310")
    setting_window.title("设置")


    add_var = tk.IntVar()
    sub_var = tk.IntVar()
    mul_var = tk.IntVar()
    div_var = tk.IntVar()
    def check():
        if (add_var.get() == 0) & (sub_var.get() == 0) & (mul_var.get() == 0) & (div_var.get() == 0):
            op_list.clear()
            op_list.append("+")
            op_list.append("-")
            op_list.append("*")
            op_list.append("/")
        elif (add_var.get() == 1) & (sub_var.get() == 0) & (mul_var.get() == 0) & (div_var.get() == 0):
            op_list.clear()
            op_list.append("+")
        elif (add_var.get() == 0) & (sub_var.get() == 1) & (mul_var.get() == 0) & (div_var.get() == 0):
            op_list.clear()
            op_list.append("-")
        elif (add_var.get() == 0) & (sub_var.get() == 0) & (mul_var.get() == 1) & (div_var.get() == 0):
            op_list.clear()
            op_list.append("*")
        elif (add_var.get() == 0) & (sub_var.get() == 0) & (mul_var.get() == 0) & (div_var.get() == 1):
            op_list.clear()
            op_list.append("/")
        elif (add_var.get() == 1) & (sub_var.get() == 1) & (mul_var.get() == 0) & (div_var.get() == 0):
            op_list.clear()
            op_list.append("+")
            op_list.append("-")
        elif (add_var.get() == 1) & (sub_var.get() == 0) & (mul_var.get() == 1) & (div_var.get() == 0):
            op_list.clear()
            op_list.append("+")
            op_list.append("*")
        elif (add_var.get() == 1) & (sub_var.get() == 0) & (mul_var.get() == 0) & (div_var.get() == 1):
            op_list.clear()
            op_list.append("+")
            op_list.append("/")
        elif (add_var.get() == 0) & (sub_var.get() == 0) & (mul_var.get() == 1) & (div_var.get() == 1):
            op_list.clear()
            op_list.append("*")
            op_list.append("/")
        elif (add_var.get() == 0) & (sub_var.get() == 1) & (mul_var.get() == 1) & (div_var.get() == 0):
            op_list.clear()
            op_list.append("-")
            op_list.append("*")
        elif (add_var.get() == 0) & (sub_var.get() == 1) & (mul_var.get() == 0) & (div_var.get() == 1):
            op_list.clear()
            op_list.append("-")
            op_list.append("/")
        elif (add_var.get() == 1) & (sub_var.get() == 1) & (mul_var.get() == 1) & (div_var.get() == 0):
            op_list.clear()
            op_list.append("+")
            op_list.append("-")
            op_list.append("*")
        elif (add_var.get() == 1) & (sub_var.get() == 1) & (mul_var.get() == 0) & (div_var.get() == 1):
            op_list.clear()
            op_list.append("+")
            op_list.append("-")
            op_list.append("/")
        elif (add_var.get() == 1) & (sub_var.get() == 0) & (mul_var.get() == 1) & (div_var.get() == 1):
            op_list.clear()
            op_list.append("+")
            op_list.append("*")
            op_list.append("/")
        elif (add_var.get() == 0) & (sub_var.get() == 1) & (mul_var.get() == 1) & (div_var.get() == 1):
            op_list.clear()
            op_list.append("-")
            op_list.append("*")
            op_list.append("/")
        elif (add_var.get() == 1) & (sub_var.get() == 1) & (mul_var.get() == 1) & (div_var.get() == 1):
            op_list.clear()
            op_list.append("+")
            op_list.append("-")
            op_list.append("*")
            op_list.append("/")
        else:
            print("There is something")
    def set_ok():
        if int(low_limit_entry.get()) <= int(height_limit_entry.get()):
            setting_window.destroy()
        else:
            tkinter.messagebox.showerror(message="下限必须低于或等于上限!")
    low_limit_label = tk.Label(setting_window, text="下限")
    low_limit_label.place(x=10, y=10)
    low_limit_entry = tk.Entry(setting_window, width=10, textvariable=low_limit)
    low_limit_entry.place(x=50, y=10)
    height_limit_label = tk.Label(setting_window, text="上限")
    height_limit_label.place(x=10, y=40)
    height_limit_entry = tk.Entry(setting_window, width=10, textvariable=height_limit)
    height_limit_entry.place(x=50, y=40)
    add_check = tk.Checkbutton(setting_window, text="加法", onvalue=1,offvalue=0,variable=add_var, command=check)
    add_check.place(x=10, y=70)
    sub_check = tk.Checkbutton(setting_window, text="减法",onvalue=1, offvalue=0, variable=sub_var, command=check)
    sub_check.place(x=10, y=100)
    mul_check = tk.Checkbutton(setting_window, text="乘法", onvalue=1, offvalue=0, variable=mul_var, command=check)
    mul_check.place(x=10, y=130)
    div_check = tk.Checkbutton(setting_window, text="除法", onvalue=1, offvalue=0, variable=div_var, command=check)
    div_check.place(x=10, y=160)
    ok_button = tk.Button(setting_window, text="确定", width=10, height=1,command=set_ok)
    ok_button.place(x=10,y=200)
    cancel_button = tk.Button(setting_window, text="取消", width=10, height=1, command=setting_window.destroy)
    lebel = tk.Label(setting_window, width=30, height=4, text="""
所有设置将在下一题生效
运算设置在试卷生成器中依然有效
取值范围请在试卷生成器中单独设置""")
    lebel.place(x=0, y=230)
    cancel_button.place(x=100,y=200)

    setting_window.mainloop()

def more():
    
    more_winndow = tk.Toplevel(window)
    more_winndow.geometry("200x200")
    more_winndow.title("更多")

    def divide():
        more_winndow.destroy()
        divide_window = tk.Toplevel(window)
        divide_window.geometry("200x300")
        divide_window.title("分拆器")

        divide_var = tk.StringVar()
        def start_divide():
            divide_text.delete("1.0", "end")
            time = 1
            time_2 = -1
            try:
                if int(divide_var.get()) >= 0:
                    for i in range(int(divide_var.get())):
                        var_1 = time
                        var_2 = int(divide_var.get())-time
                        divide_text.insert("end", chars=f"{var_1}   {var_2}\n")
                        time += 1
                else:
                    for i in range(int(divide_var.get()) * -1):
                        var_1 = time_2
                        var_2 = int(divide_var.get()) - time_2
                        divide_text.insert("end", chars=f"{var_1}   {var_2}\n")
                        time_2 -= 1
            except ValueError:
                tkinter.messagebox.showwarning(message="请输入一个数字")
        divide_label = tk.Label(divide_window, text="基数(分拆每个数字的和)")
        divide_label.place(x=0, y=0)
        divide_entry = tk.Entry(divide_window, textvariable=divide_var, width=5)
        divide_entry.place(x=150, y=0)
        divide_button = tk.Button(divide_window, text="开始分拆", width=25, command=start_divide)
        divide_button.place(x=0,y=30)
        divide_text = tk.Text(divide_window, width=25, height=11)
        divide_text.place(x=0, y=80)
        def start_divide_practice():
            global divide_practice_list
            check_divide_var = tk.StringVar()
            check_question_number_var = tk.StringVar()
            check_divide_window =  tk.Toplevel(window)
            check_divide_window.geometry("300x110")
            check_divide_window.title("")
            def start_practice():
                global questtion_list
                global time_question
                divide_window.destroy()
                check_divide_window.destroy()
                
                str_check_divide_var = check_divide_var.get()
                check_question_list = str_check_divide_var.split(",")
                time_question = 0
                time_question_2 = 0
                questtion_list = []
                for i in range(len(check_question_list)):
                    for i in range(int(check_question_list[time_question])):
                        print(int(check_question_list[time_question]))
                        var_1 = time_question_2
                        var_2 = int(check_question_list[time_question]) - var_1
                        if var_1 < var_2:
                            while "-" in op_list:
                                op_list.remove("-")
                            questtion_list.append(f"{var_1} {random.choice(op_list)} {var_2}")
                            time_question_2 += 1
                        elif var_2 == 0:
                            if "/" in op_list:
                                op_list.remove("/")
                                questtion_list.append(f"{var_1} {random.choice(op_list)} {var_2}")
                                time_question_2 += 1
                            else:
                                questtion_list.append(f"{var_1} {random.choice(op_list)} {var_2}")
                                time_question_2 += 1
                        else:
                            questtion_list.append(f"{var_1} {random.choice(op_list)} {var_2}")
                            time_question_2 += 1
                    time_question += 1
                if len(questtion_list) > int(check_question_number_var.get()):
                    questtion_list = questtion_list[:(int(check_question_number_var.get()))]
                print(questtion_list)
                choose_uestion = random.choice(questtion_list)
                question_label.config(text=f"{choose_uestion}")
                questtion_list.remove(choose_uestion)
            check_divide_label = tk.Label(check_divide_window, text="输入要分拆的基数(如10或10 11)")
            check_divide_label.place(x=0, y=0)
            check_divide_entry = tk.Entry(check_divide_window, textvariable=check_divide_var, width=13)
            check_divide_entry.place(x=190, y=0)
            check_question_number_label = tk.Label(check_divide_window, text="题目数量")
            check_question_number_label.place(x=0, y=30)
            check_question_number_entry = tk.Entry(check_divide_window, textvariable=check_question_number_var, width=13)
            check_question_number_entry.place(x=190, y=30)
            check_ok_button = tk.Button(check_divide_window, text="确定", width=20, command=start_practice)
            check_ok_button.place(x=80, y=60)
        start_practice = tk.Button(divide_window, text="开始练习", width=26, command=start_divide_practice)
        start_practice.place(x=0, y=240)
    divide_b = tk.Button(more_winndow, text="分拆", width=25, command=divide)
    divide_b.pack(side="top")
    more_winndow.mainloop()
def next_pf():
    global questtion_list
    global time_question
    global choose2
    user_answer = answer_Entry.get()
    question_text = question_label.cget("text")
    if eval(user_answer) == eval(question_text):
        true_or_false.config(bg="green", text="正确")
        question_label.config(text=f"{random.choice(questtion_list)}")
        questtion_list.remove(question_label.cget("text"))
        answer.set("")
        time_question += 1
        if len(questtion_list) == 0:
            tkinter.messagebox.showinfo(message="练习已结束,点我进入普通模式")
            random_1 = random.randint(int(low_limit.get()),int(height_limit.get()))
            random_2 = random.randint(int(low_limit.get()), int(height_limit.get()))
            if random_1 < random_2 and choose2 == "-":
                random_1 = random.randint(int(low_limit.get()),int(height_limit.get()))
                random_2 = random.randint(int(low_limit.get()), int(height_limit.get()))
                question_label.config(text=f"{random_1} {choose2} {random_2}  ")
    else:
        true_or_false.config(bg="red", text=f"错误 {question_label.cget('text')} = {eval(question_label.cget('text'))}")
        question_label.config(text=f"{random.choice(questtion_list)}")
        questtion_list.remove(question_label.cget("text"))
        answer.set("")
        time_question += 1
        if len(divide_practice_list) == 0:
            tkinter.messagebox.showinfo(message="练习已结束,点我进入普通模式")
            if random_1 < random_2 and choose2 == "-":
                random_1 = random.randint(int(low_limit.get()),int(height_limit.get()))
                random_2 = random.randint(int(low_limit.get()), int(height_limit.get()))
                question_label.config(text=f"{random_1} {choose2} {random_2}  ")
question_label = tk.Label(window, width=18, height=1, bg="white", text=f"{random.randint(1,9)} {choose} {random.randint(1, 9)} ")
question_label.place(x=5,y=5)
answer_Entry = tk.Entry(window, width=5, textvariable=answer)
answer_Entry.place(x=130,y=5)
next_button = tk.Button(window, width=10, text="下一题PM", command=next)
next_button.place(x=5, y=32)
next_b = tk.Button(window, width=10, height=1, text="下一题PW", command=practice)
next_b.place(x=90, y=32)
true_or_false = tk.Label(window, width=23, height=1, bg="white")
true_or_false.place(x=5, y=100)
true = tk.Label(window, text="正确题数", width=8, height=1)
true.place(x=5, y=125)
true_number = tk.Label(window, width=14, height=1, text="0")
true_number.place(x=70, y=125)
false = tk.Label(window, width=8, height=1, text="错误题数")
false.place(x=5, y=145)
false_number = tk.Label(window, width=14, height= 1, text="0")
false_number.place(x=70, y=145)
total = tk.Label(window, width=8,  height=1, text="总题数", )
total.place(x=5, y=165)
total_number = tk.Label(window, width=14, height=1, text="0")
total_number.place(x=70, y=165)
listbox = tk.Text(window, height=9, width=20)
listbox.place(x=180, y=25)
listbox_label = tk.Label(window, width=10, height=1, text="错题集")
listbox_label.place(x=216, y=0)
again_b = tk.Button(window, height=1,width=20, text="重新开始", command=again)
again_b.place(x=5, y=190)
paper_maker_b = tk.Button(window, height=1, width=9, text="生成试卷", command=paper_maker)
paper_maker_b.place(x=5, y=225)
history_b = tk.Button(window, height=1, width=9, text="历史记录", command=history_record)
history_b.place(x=5, y=260)
setting = tk.Button(window, text="设置", width=9, height=1, command=settings)
setting.place(x=80, y=260)
cuotiben = tk.Button(window, height=1, width=9, text="生成错题本",command=cuoti)
cuotiben.place(x=170, y=155)
view_cuotiben = tk.Button(window, height=1, width=9, text="查看错题本", command=v_cuoti)
view_cuotiben.place(x=245, y=155)
reset_cuotiben = tk.Button(window, height=1, width=20, text="重置错题本(文件)", command=reset_ctb)
reset_cuotiben.place(x=170, y=190)
reset_listbox = tk.Button(window, height=1, width=20, text="重置错题集(数据可能丢失)", command=reset_ctj)
reset_listbox.place(x=170, y=225)
practice_wrong = tk.Button(window, height=1, width=20, text="练错题", command=practice)
practice_wrong.place(x=170, y=260)
more_tool = tk.Button(window, text="更多工具", width=9, command=more)
more_tool.place(x=80, y=225)
next_pf = tk.Button(window,text="下一题PF", width=23, command=next_pf)
next_pf.place(x=0, y=65)

window.mainloop()

  • 7
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值