Bootstrap

python - 我的题库程序设计 —— 非教程(Windows)【内置代码】

程序设计语言

python3.x

使用(版本:1.51)

1.58的我没有录,姑且现有1.51做参考

python自开发考试题库!

题库的所有代码(版本:1.58):



# -*- unicode:utf-8 -*-
'''The document of file

	本程序为开源软件欢迎各位使用,作者:刘博源
	学校:绵阳市游仙职业技术学校2017 级18班
    QQ:3536429078
    B站账号:青空石
    Github:开源下载:暂无
    CSDN:https://blog.csdn.net/tc9527_

'''
import random,pickle
import tkinter as tk
from tkinter import filedialog
from time import time,sleep
import os
import sys,win32gui
from openpyxl import load_workbook  # 导入模块
import tkinter.messagebox as msg
import numpy as np
import matplotlib.pyplot as plt
import json
from docx.enum.text import WD_ALIGN_PARAGRAPH
import docx
from docx.oxml.ns import qn
from docx.shared import Pt
from multiprocessing import Pool
from tkinter import simpledialog
from tkinter.scrolledtext import ScrolledText
UserNameFu = None
def read_pickle(filename,data=[]):
    try:
        with open(filename,'rb') as f:
            return pickle.load(f)
    except IOError as error:
        print(error)
        with open(filename,'wb') as f:
            return pickle.dump(data,f)
        read_pickle(filename,data)
def read( file):
    with open(file,'r') as F:
        return json.load(F)
def send(cmd):
    try:
        with open("../data.1",'r') as f:
            a = f.read()
        with open("../data.1",'w') as f:
            f.write(cmd)
    except:
        with open("./data.1",'w') as f:
            f.write(cmd)
class JianDu():
    def __init__(self):

        self.Leavel_root_count = read("ALLL.json")

    def clear(self): #还原
        self.Leavel_root_count = read("ALLL.json")

    def Main(self):
        print("请勿作弊,考试进程开启")
        chage = 0
        with open(r"./data.1",'w') as f:
            f.write("No")
        with open("./DPI.data",'rb') as  f:
            dpi = pickle.load(f)
        while True:
            with open(r'./data.1','r') as f:
                mode = f.read() # 获取指令
            # print(mode)
            if mode == 'Yes': # 进程启动
                print("进程启动5")
                if chage == 0:
                    self.Leavel_root_count = read("ALLL.json")
                window = win32gui.GetForegroundWindow()
                window_name = win32gui.GetWindowText(window)
                # print(window_name)
                # if mode
                sleep(1)
                if window_name in 'Tips确定删除返回错误成功完成Tip题库1.58刷题宝-登录tk考试中..我的笔记本,双击选择文件!主菜单':
                    print("一切正常")
                else:
                    while True:
                        window = win32gui.GetForegroundWindow()
                        window_name = win32gui.GetWindowText(window)
                        if window_name in 'Tips确定删除返回错误成功完成Tip题库1.58刷题宝-登录tk考试中..我的笔记本,双击选择文件!主菜单':
                            self.Leavel_root_count=self.Leavel_root_count-1

                            if self.Leavel_root_count > 0:
                                print("触发")
                                chage = 1
                                warn = tk.Tk()
                                warn.title("Tip")
                                warn.geometry("%sx%s"%(dpi[0],dpi[1]))
                                warn.wm_attributes('-topmost', 1)
                                warn.overrideredirect(True)
                                import tkinter.messagebox
                                # tk.Tk().withdraw()
                                tk.Label(warn,text="系统监测你退出了程序,现在为你扣一分\n你还有%s次机会(切勿按住Alt+F4关闭程序,否则有几率退出考试)\n点击窗口退出程序"%(self.Leavel_root_count)).place(x=dpi[0]/2,y=dpi[1]/2)
                                # msg.showinfo("Tip","系统监测你退出了程序,现在为你扣一分\n你还有%s次机会(请先回到考试界面再关闭我)"%(self.Leavel_root_count))
                                # break
                                # time.sleep(1)
                                def a(event):
                                    warn.destroy()
                                warn.bind("<Button-1>",a )
                                warn.mainloop()
                                break # break 在最后
                            else:
                                print("触发")
                                chage = 1
                                warn = tk.Tk()
                                warn.title("Tip")
                                warn.geometry("%sx%s" % (dpi[0], dpi[1]))
                                warn.wm_attributes('-topmost', 1)
                                warn.overrideredirect(True)
                                import tkinter.messagebox
                                # tk.Tk().withdraw()
                                tk.Label(warn,
                                         text="考试已被强制性结束,程序退出" ).place(x=dpi[0]/2,y=dpi[1]/2)

                                # msg.showinfo("Tip","系统监测你退出了程序,现在为你扣一分\n你还有%s次机会(请先回到考试界面再关闭我)"%(self.Leavel_root_count))
                                # break
                                # time.sleep(1)
                                def a(event):
                                    with open("pid.data", 'rb') as f:
                                        pid_F = pickle.load(f)
                                    os.popen('taskkill.exe /pid:' + str(pid_F)) # 结束主进程
                                    pid = os.getpid()
                                    os.popen('taskkill.exe /pid:' + str(pid)) # 结束子进程


                                warn.bind("<Button-1>", a)
                                warn.mainloop()
                                break  # break 在最后
                    else:
                        pass



            if mode == "close": # 程序退出
                return
            if mode == "pass":  # 考试结束
                self.Leavel_root_count = read("ALLL.json")

class Caozuo(): #用于操作题库获取信息与写入错题
    def __init__(self):

        self.wb = load_workbook ( filename="题库.xlsx" )

        self.sheet_TiKu = self.wb["题库"]
        self.sheet_CuoTi = self.wb["类型一栏"]

    def Check( self ): #获取题库的问题总数
        for i in range(1,10000):
            name = "A%s"%(i)
            # print(self.sheet_TiKu[name].value)
            if self.sheet_TiKu[name].value == None:
                # print(i-1)
                return i-1
            else:pass
    def Check_A( self ):
        wb = load_workbook ( filename="错题集.xlsx" )
        ws = wb["错题集"]
        for i in range(1,10000):
            name = "A%s" %(i)
            if ws[name].value == None:
                return i-1
    def Check_B(self):
        wb = load_workbook(filename="./../题库.xlsx")
        ws = wb["题库"]
        for i in range(1, 10000):
            name = "A%s" % (i)
            if ws[name].value == None:
                return i - 1
    def Add_TiKu(self,list,type): # 题库修改
        wb = load_workbook(filename="./../题库.xlsx")
        ws = wb["题库"]
        coun = self.Check_() + 1
        if coun == 1:
            coun = 2
        for L in list:
            i = str(coun)

            TiGan = "A" + i
            A = "B" + i
            B = "C" + i
            C = "D" + i
            D = "E" + i
            T = "F" + i
            Y = "G" + i
            ws[TiGan] = L[0]
            ws[A] = L[1]
            ws[B] = L[2]
            ws[C] = L[3]
            ws[D] = L[4]
            ws[T] = L[5]
            ws[Y] = type
            coun += 1
        wb.save("./../题库.xlsx")
    def write_TiKu( self ,List): # 记录错题
        def main():
            wb = load_workbook ( filename="错题集.xlsx" )
            ws = wb["错题集"]
            ws["A1"] = "题干"
            ws["B1"] = 'A选项'
            ws["C1"] = 'B选项'
            ws["D1"] = "C选项"
            ws["E1"] = "D选项"
            ws["F1"] = "正确答案"
            ws["G1"] = "你的答案"
            print("记录错题中...")
            coun = self.Check_A()+1
            if coun == 1:
                coun = 2
            for L in List:

                    i = str(coun)


                    TiGan = "A" + i
                    A = "B" + i
                    B = "C" + i
                    C = "D" + i
                    D = "E" + i
                    T = "F" + i
                    Y = "G" + i
                    ws[TiGan] = L[0]
                    ws[A] = L[1]
                    ws[B] = L[2]
                    ws[C] = L[3]
                    ws[D] = L[4]
                    ws[T] = L[5]
                    ws[Y] = L[6]
                    coun += 1
            wb.save("./错题集.xlsx")
        main()



    def read_TiKu_type(self,type=None,modle="T"): # 函数有两种模式 modle="T"时  return 题库的类型 为F时 返回符合type的题
        if modle == "T":
            row = 1
            list = []
            while True:
                name = "A%s"%(row)

                if self.sheet_CuoTi[name].value == None:
                    break
                else:
                    list.append(self.sheet_CuoTi[name].value)
                    row += 1

            print(list);return list
        elif modle == "F":

            List_check = [] #c存储符合条件的单元格列数
            end = self.Check() + 1
            # print("end -- %s"%(end))

            for i in range(2,end):
                type_row = "G%s"%(i)
                if type == None:
                    List_check.append(i)
                elif type != None:
                    if self.sheet_TiKu[type_row].value == type:
                        List_check.append(i)
                    # print(i)
            if List_check == []:
                tk.messagebox.showerror('Tip',"该类型的题目数为0")
            else:
                Len = len(List_check)
                # print(List_check)
                print("已为你找到了%s道类似的题"%(Len))
            All = []

            for i in List_check:
                Tigan = "A%s" % (i)
                A = "B%s" % (i)
                B = "C%s" % (i)
                C = "D%s" % (i)
                D = "E%s" % (i)
                True_Answer = "F%s" % (i)
                type_que = "G%s" % (i)
                List = [self.sheet_TiKu[Tigan].value , self.sheet_TiKu[A].value ,
                        self.sheet_TiKu[B].value , self.sheet_TiKu[C].value ,
                        self.sheet_TiKu[D].value , self.sheet_TiKu[True_Answer].value,self.sheet_TiKu[type_que].value]
                # print ( List )
                All.append ( List )
            return All


    def read_TiKu( self ,Number=0): #随机返回一个问题列表([问题,A,B,C,D,True答案])
        Num = self.Check()
        # print(Num)
        if Number == 0:
            Number = random.randint(2,Num)
        else:
            Number += 1
        Name_WenTi = "A%s"%(Number)
        Name_A = "B%s"%(Number)
        Name_B = "C%s"%(Number)
        Name_C = "D%s"%(Number)
        Name_D = "E%s"%(Number)
        Name_key = "F%s"%(Number)
        return [self.sheet_TiKu[Name_WenTi].value,
                self.sheet_TiKu[Name_A].value,
                self.sheet_TiKu[Name_B].value,
                self.sheet_TiKu[Name_C].value,
                self.sheet_TiKu[Name_D].value,
                self.sheet_TiKu[Name_key].value
                ]
    def Cuoti(self): # 返回所有的错题
        must = self.Check_A()

        List = []
        wb = load_workbook ( filename="错题集.xlsx" )
        sheet_CuoTi = wb["错题集"]
        for Number in range(2,must):
            Name_WenTi = "A%s" % (Number)
            Name_A = "B%s" % (Number)
            Name_B = "C%s" % (Number)
            Name_C = "D%s" % (Number)
            Name_D = "E%s" % (Number)
            Name_key = "F%s" % (Number)
            Name_you = "G%s" % (Number)
            List.append((sheet_CuoTi[Name_WenTi].value,
                sheet_CuoTi[Name_A].value,
                sheet_CuoTi[Name_B].value,
                sheet_CuoTi[Name_C].value,
                sheet_CuoTi[Name_D].value,
                sheet_CuoTi[Name_key].value,
                sheet_CuoTi[Name_you].value))
        #添加
        #去重
        Set = set(List)
        List = list(Set)
        print("已去重")
        return List
class Windows():
    def __init__(self):
        self.Frist = [True,True]
        self.font = 18
        self.ask = None
        self.start_time = 0
        self.end_time = 0
        # 考试开始与结束的时间
        self.FenShu = 0
        self.indexa = 0 # 考试的索引值
        self.mode = False #是否进入了答题模式
        self.Leavel_root_number =0
        self.c = 0 # 首次打开程序弹出的窗口,在弹出之后便不在弹出(打开程序只弹一次)
        self.Check_List = []
        self.True_Answer_type = None
        self.Update_list = None
        self.count=0
        self.change = 3
        self.Error = []
        self.mark=0
        self.geometry = True
        self.True_count = 0




        try:
            self.All = read ( "AL" )  # 考试总题数
        except FileNotFoundError as e:
            print("文件阅读错误!(无大碍报错)")
        print("已经还原为初始化状态")

        try:
            self.tool = Caozuo ( )
            self.root = tk.Tk()
            self.root.title("题库1.58")
            self.root.iconbitmap('./main.ico')
            self.Username = UserNameFu
            self.root.geometry("250x250")
            os.chdir ( "./%s"%(UserNameFu) )

            with open("./data2.json",'r') as f:
                self.dict = json.load(f)
            self.Main()


            self.root.resizable(False,False)

            self.root.mainloop()

            sys.exit()
        except:
            pass
    def Worre( self ):
        msg.showinfo("Tips","由于宽度限制,用户可以自行调整其宽度")
        self.root.resizable(True,True)
        PZ1 = tk.Label (self.root)
        PZ1.place ( rely=0 , relx=0 , relwidth=1 , relheight=1 )
        self.root.geometry("1520x400")
        List = self.tool.Cuoti()
        print(List)
        T = ScrolledText(font=("隶书",18))
        T.place(x=60, y=30,relwidth=0.9,relheight=1)
        def add():
            self.font += 1
            T["font"] = ("隶书",self.font)
        Font_add = tk.Button(text=" A+(字体加大) ",command=add)
        def cost():
            if self.font >= 0:
                self.font -= 1
            else:
                msg.showinfo("Tip","字体太小了")
            T["font"] = ("隶书", self.font)
        Font_cosr = tk.Button(text=" A-(字体减小) ",command=cost)
        Font_add.place(rely=0,x=90)
        Font_cosr.place(rely=0,x=360)

        for i in List:
            text = "%s\n A.%s\n B.%s\n C.%s\n D.%s\n你的答案:%s\n正确答案:%s\n       " %(i[0],i[1],i[2],i[3],i[4],i[6],i[5])
            T.insert('end' , text)
            T.insert('end', ' \n')

    def setting( self ):
        PZ1 = tk.Label(self.root)
        PZ1.place(rely=0,relx=0,relwidth=1,relheight=1)
        t = tk.Label(self.root,text="出题数目:")
        t.place(relx=0, rely=0.01)
        v = tk.StringVar ( )
        v2 = tk.StringVar()
        s2 = tk.Scale (self.root,
                     from_=1 ,  # 设置最小值
                     to=100 ,  # 设置最大值
                     orient=tk.HORIZONTAL ,  # 设置横向
                     resolution=1 ,  # 设置步长
                     tickinterval=10 ,  # 设置刻度
                     length=240 ,  # 设置像素
                     variable=v )  # 绑定变量
        s2.place (relx=0,rely=0.1
                  )
        t2 = tk.Label(self.root,text="做题时,允许离开答题界面次数:")
        t2.place(relx=0,rely=0.4)
        s3 = tk.Scale(self.root,
                      from_=1,  # 设置最小值
                      to=100,  # 设置最大值
                      orient=tk.HORIZONTAL,  # 设置横向
                      resolution=1,  # 设置步长
                      tickinterval=10,  # 设置刻度
                      length=240,  # 设置像素
                      variable=v2)  # 绑定变量
        s3.place(relx=0,rely=0.5)

        def S():
            self.Leavel_root_count = int(v2.get())
            self.All = int(v.get())
            if msg.askquestion("Tip",'确认保存?你需要重启才可以生效\n(目前答题界面只适用于考试模块,并无法运用于专题测试)') == 'yes':
                msg.showinfo("Tip","已将出题数修改为%s\n允许离开答题界面次数修改为%s"%(self.All,self.Leavel_root_count))
                with open("../AL","w") as F:
                    json.dump(self.All,F)
                with open("../ALLL.json","w") as F:
                    json.dump(self.Leavel_root_count,F)
                s2.destroy()

            a.destroy()
            self.Main()


        a = tk.Button(self.root,text="保存",command=S)
        a.place(relx=0.7,rely=0)

    def delet( self ):
        if msg.askquestion("确定删除","删除是不可逆的操作,请稍加思考(按是继续)") == 'yes':
            name = read("../pass.json")
            name.pop(UserNameFu)
            self.root.destroy()
            with open("../pass.json",'w') as F:
                json.dump(name,F)
            os.chdir ( "../" )


    def Add(self,type_que,mode=1): #mode代表分数
        # type_que = Choose.get()
        if type_que in ['计算机基础(办公)', '计算机基础(文化)']:
            type_que = "计算机基础"
        elif type_que == "数据库":
            type_que = "计算机数据库"
        try:
            if mode == 1:
                self.dict[type_que] += 1
            if mode == -1:
                self.dict[type_que] -= 1
        except Exception as ex:
                print(ex)
    def Z_KaoShi(self):
        self.Error = []
        from tkinter import ttk
        PZ1 = tk.Label (self.root )
        msg.showinfo ( "Tip" , "由于宽度限制,用户可以自行调整其宽度" )
        self.root.resizable ( True , False )
        list_type = self.tool.read_TiKu_type()
        PZ1.place ( rely=0 , relx=0 , relwidth=1 , relheight=1 )
        Tip = tk.Label(self.root,text="请选择考试试卷类型:")

        Tip.place(relx=0.2,rely=0.3)
        Choose = ttk.Combobox(self.root)



        Choose["values"] = list_type


        def Start():



            self.Update_list = random.choice ( self.tool.read_TiKu_type ( modle="F" , type=Choose.get ( ) ) )
            self.True_Answer_type = random.choice(self.Update_list[5])

            print ( ">>>%s"%(self.Update_list) )
            if Choose.get() in list_type:
                All = self.tool.read_TiKu_type(modle="F",type=Choose.get())
                #Over There Is Type Que
                PZ1 = tk.Label ( self.root)
                count = 0
                Must = len(All)

                if All != []:
                    def randon_index():
                        print(Must)
                        random_index = random.randint(1,Must)
                        return random_index
                    count = self.All
                    def update(key):#1.检查题,加分或不加分 2.刷新界面,修改题目

                        if self.True_Answer_type == key: # 做对了
                            # print(Tiw[ans])
                            self.True_count += 1
                            self.dict['正确率'] += 2
                            self.Add(type_que=Choose.get()) # 专项得分

                            # print(Tiw[ans][5])
                            # self.Update_list = random.choice (
                            # self.tool.read_TiKu_type ( modle="F" , type=Choose.get ( ) ) )
                            # self.True_Answer_type = random.choice ( self.Update_list[5] )
                            Start()

                        else:
                            self.Add(type_que=Choose.get(),mode=-1)# 专项减分
                            if self.dict['正确率']>0:self.dict['正确率'] -= 2
                            else:self.dict['正确率'] = 0
                            name = read('data1.json')
                            if self.True_count > name:
                                with open("data1.json",'w') as f:
                                    json.dump(self.True_count,f)
                                msg.showinfo('Tip',"恭喜你,你成功的做到了连对 %s 道题刷新了之前连对 %s 道题的记录,\n继续做题吧"%(self.True_count,name))
                            self.True_count = 0
                            self.Error.append(self.Update_list)
                            tk.messagebox.showerror("Tip","你把这题想的太简单了\n再试试吧")
                            self.change -= 1
                            if self.change == 0:
                                with open('./data2.json','w') as f:
                                    json.dump(self.dict,f)
                                print(self.dict)
                                chanage = tk.messagebox.askquestion ( '考试结束' , "你已经没有机会了,考试结束\n是否保存错题" )
                                # print(chanage)
                                if chanage == 'yes':

                                    self.tool.write_TiKu(self.Error)
                                self.Main()
                                print("谢谢使用")

                                self.mark = 0
                                self.change=3


                        # print ( self.Update_list )
                        # print ( self.True_Answer_type )


                    def A():
                        update("A")

                    def D():
                        update("D")

                    def C():
                        update("C")

                    def B():
                        update("B")

                    PZ1 = tk.Label (self.root )
                    PZ1.place ( rely=0 , relx=0 , relwidth=1 , relheight=1 )
                    self.root.geometry ( "400x400" )
                    a = randon_index()
                    # show.place ( rely=0 , relx=0 )
                    # print(Ti)
                    TiGan = tk.Text ( self.root)
                    # print(a)
                    TiGan.place ( relx=0.15 , rely=0.1 , relwidth=0.7 , relheight=0.2 )
                    TiGan.insert ( 'end' , self.Update_list[0] )
                    if len(self.Update_list[5]) == 1:
                        A = tk.Button (self.root, command=A , text="A.%s" % (self.Update_list[1]) )
                        A.place ( relx=0.15 , rely=0.3 )
                        B = tk.Button (self.root, command=B , text="B.%s" % (self.Update_list[2]) )
                        B.place ( relx=0.15 , rely=0.4 )
                        C = tk.Button ( self.root,command=C , text="C.%s" % (self.Update_list[3]) )
                        C.place ( relx=0.15 , rely=0.5 )
                        D = tk.Button ( self.root,command=D , text="D.%s" % (self.Update_list[4]) )
                        D.place ( relx=0.15 , rely=0.6 )
                    else:
                        def Check_result():
                            if vara.get ( ) == 1:
                                self.Check_List.append ( "A" )
                            if varb.get ( ) == 1:
                                self.Check_List.append ( "B" )
                            if varc.get ( ) == 1:
                                self.Check_List.append ( "C" )
                            if vard.get ( ) == 1:
                                self.Check_List.append ( "D" )
                            result = ''
                            for i in self.Check_List:
                                result += i
                            print ( result )
                            if result == Ti[5]:
                                self.dict['正确率'] += 2
                                Start()



                            else:
                                if self.dict['正确率'] > 0:
                                    self.dict['正确率'] -= 2
                                else:
                                    self.dict['正确率'] = 0
                                name = read ( 'data1.json' )
                                if self.True_count > name:
                                    with open ( "data1.json" , 'w' ) as f:
                                        json.dump ( self.True_count , f )
                                    msg.showinfo ( 'Tip' , "恭喜你,你成功的做到了连对 %s 道题刷新了之前连对 %s 道题的记录,\n继续做题吧" % (
                                    self.True_count , name) )
                                self.True_count = 0
                                self.Error.append ( self.Update_list )
                                tk.messagebox.showerror ( "Tip" , "你把这题想的太简单了\n再试试吧" )
                                self.change -= 1
                                if self.change == 0:
                                    with open('../data.1','w') as f:
                                        f.write("No")
                                    chanage = tk.messagebox.askquestion ( '考试结束' , "你已经没有机会了,考试结束\n是否保存错题" )
                                    # print(chanage)
                                    if chanage == 'yes':
                                        self.tool.write_TiKu ( self.Error )
                                    self.Main ( )
                                    print ( "谢谢使用" )

                            self.Check_List = []
                        vara = tk.IntVar ( )
                        varb = tk.IntVar ( )
                        varc = tk.IntVar ( )
                        vard = tk.IntVar ( )
                        Ti = self.Update_list

                        A = tk.Checkbutton ( self.root,variable=vara , text="A.%s" % (Ti[1]) , onvalue=1 , offvalue=0 )
                        A.place ( relx=0.15 , rely=0.3 )
                        B = tk.Checkbutton ( self.root,variable=varb , text="B.%s" % (Ti[2]) , onvalue=1 , offvalue=0 )
                        B.place ( relx=0.15 , rely=0.4 )
                        C = tk.Checkbutton ( self.root,variable=varc , text="C.%s" % (Ti[3]) , onvalue=1 , offvalue=0 )
                        C.place ( relx=0.15 , rely=0.5 )
                        D = tk.Checkbutton ( self.root,variable=vard , text="D.%s" % (Ti[4]) , onvalue=1 , offvalue=0 )
                        D.place ( relx=0.15 , rely=0.6 )
                        result = tk.Button (self.root, text="提交" , command=Check_result )
                        result.place ( relx=0.15 , rely=0.7 )
                    # self. = Ti[a][5]
                # import time;
                # time.sleep ( 2 )
                #
            else:
                tk.messagebox.showerror("Tip","没有这种类型.")


        Choose.place(relx=0.15,rely=0.4)

        Choose.current(0)
        Button_Goit = tk.Button(self.root,text="开始",command=Start)
        Button_Goit.place(relx=0.20,rely=0.62)
        Button_Back = tk.Button (self.root, text="回去" , command=self.Main )
        Button_Back.place ( relx=0.60 , rely=0.62 )
    def back( self ):

        def p(e):
            pass
        self.root.bind_all('<Control-s>',p)
        self.root.bind_all('<Control-S>',p)
        # msg.askquestion(title="返回", message="确定返回???") == "yes"
        if True:
            self.Main()
            self.mark = 0
            self.root.title("主菜单")
            self.root.resizable(False, False)
            self.__init__()

    def aim( self ):
        msg.showinfo("Tip",'抬头看天空,低头看脚步,既要有追求,也要有务实')
        PZ1 = tk.Label(self.root)
        PZ1.place(rely=0,relx=0,relwidth=1,relheight=1)
        self.root.geometry("500x550")
        NameLabel_1 = tk.Label(self.root,text="刷题新手\n在一次专题测试中,连对10道题",font=('中华金榜体-向佳红字迹',16))
        NameLabel_1.place(relx=0.12,rely=0.12)
        if read('data1.json') >= 10:
            NameLabel_1["fg"] = 'red'
            NameLabel_1['text'] = "刷题新手\n在一次专题测试中,连对10道题\n万里长征第一步"
        NameLabel_2 = tk.Label(self.root,text="练题达人\n在一次专题测试中,连对20道题",font=('中华金榜体-向佳红字迹',16))
        NameLabel_2.place(relx=0.12,rely=0.32)
        if read('data1.json') >= 20:
            NameLabel_2["fg"] = 'green'
            NameLabel_2['text'] = "练题达人\n在一次专题测试中,连对20道题\n任何事情都不是一蹴而就的"
        NameLabel_3 = tk.Label(self.root,text="练题高手\n在一次专题测试中,连对50道题",font=('中华金榜体-向佳红字迹',16))
        NameLabel_3.place(relx=0.12,rely=0.52)
        if read('data1.json') >= 50:
            NameLabel_3["fg"] = 'blue'
            NameLabel_3['text'] = '练题高手\n在一次专题测试中,连对50道题\n高手从不满与现状'
        PZ1.place ( rely=0 , relx=0 , relwidth=1 , relheight=1 )
        NameLabel_4 = tk.Label ( self.root,text="一点通\n在一次专题测试中,连对80道题" , font=('中华金榜体-向佳红字迹' , 16) )
        NameLabel_4.place ( relx=0.12 , rely=0.72 )
        if read ( 'data1.json' ) >= 80:
            NameLabel_4["fg"] = 'pink'
            NameLabel_4['text'] = '一点通\n在一次专题测试中,连对80道题\n永不停歇,不忘初心\n恭喜你已经完成了所有的目标,\n但愿六月你会如愿以偿的考上本科。'
        PZ1.place ( rely=0 , relx=0 , relwidth=1 , relheight=1 )
    def Notebook(self):
        self.root.title("我的笔记本,双击选择文件!")
        def save(loade):
            with open("NotePad.data",'wb') as f:
                pickle.dump(loade,f)

        def B_SAVE(event=None):
            choose = self.Frist[0]
            load[choose]=T.get('0.0', 'end')
            save(load)
            msg.showinfo("Tip",'笔记已修改,并保存')
            self.Frist=[choose,T.get('0.0', 'end')]


        tk.Label().place(relwidth=1, relheight=1)
        self.root.geometry("1000x500")
        load = read_pickle("NotePad.data",data={"计算机基础":'计算机基础一览:','计算机数据库':'计算机数据库一览:','计算机网络':'计算机网络一览:'})
        title=[]
        # text=[]
        for k in load.keys():
            title.append(k)
        # for v in load.values():
        #     text.append(v)
        List_tit = tk.Listbox()
        List_tit.place(x=0,y=0)
        for i in title:
            List_tit.insert(1,i)
        def B_DEL(event=None):
            choose = self.Frist[0]
            if msg.askquestion("Tip","确认删除 %s 笔记吗?"%(choose))=='yes':
                List_tit.delete(self.ask)
                del load[choose]
                msg.showinfo("Tip",'已经删除文件')
                title.remove(choose)
            save(load)

        def Add_NOTE():
            t = simpledialog.askstring("标题",'请输入笔记的标题(无法修改!!)')
            if t == None:
                return
            elif t in title:
                msg.showinfo("Tip","与现有的笔记标题重名!")
            else:
                print(title)
                load[t] = ''
                List_tit.insert(1,t)
                title.append(t)
                save(load)
        T = ScrolledText()
        T.place(x=200,y=0)


        e2 = tk.IntVar()
        E = tk.Entry(show=None, textvariable=e2)
        E.place(x=0,y=250)
        e2.set("双击标题,编辑或查看文件")
        B = tk.Button(text="保存\nCtrl+S快捷键",command=B_SAVE)
        B.place(x=20,y=300)
        A = tk.Button(text="删除\nDelete快捷键", command=B_DEL)
        A.place(x=20, y=410)
        self.root.bind_all('<Control-s>',B_SAVE)
        self.root.bind_all('<Control-S>',B_SAVE)
        Add_note = tk.Button(text=' + ',command=Add_NOTE)
        Add_note.place(x=165,y=0)
        def Select(e):

            if self.Frist != [True,True]:

                text_after = T.get('0.0', 'end')
                print("文本%s 结束"%(text_after))
                if text_after != self.Frist[1]:
                    if msg.askquestion("Tip","你已经修改过当前笔记,是否保存") == 'yes':
                        load[self.Frist[0]] = text_after
                        save(load)
                        choose = List_tit.get(List_tit.curselection())
                        text = load[choose]

                        T.delete('1.0', 'end')
                        T.insert('end', text)
                        self.Frist = [choose, T.get('0.0', 'end')]


            choose = List_tit.get(List_tit.curselection())
            self.ask = List_tit.curselection()
            print("执行")
            e2.set("加载笔记:%s"%(choose))
            text = load[choose]
            T.delete('1.0','end')
            T.insert('end' , text)
            self.Frist = [choose, T.get('0.0', 'end')]

        List_tit.bind("<Double-Button-1>",Select)




    def Main( self ):
        self.root.geometry("250x250")

        def Update():
            msg.showwarning('Tip',"正在开发...")

        def get(event):

            choose = ListZhiShi.get(ListZhiShi.curselection())
            if choose == "考试":
                self.KaoShi()
            elif choose == "删号":
                self.delet()
            elif choose == "错题回顾":
                msg.showinfo("错误","还没有开发出来")
            elif choose == "设置":
                self.setting()
            elif choose == "退出":
                result = msg.askquestion("Tip", "是否退出")
                if result == "yes":
                    self.root.destroy()
                else:
                    print(result)
            elif choose == "专题测试":
                self.Z_KaoShi()
            elif choose == "查看错题":
                self.Worre()
            elif choose == '账号更新':
                update()
            elif choose == '实力':
                self.LeiDa()
            elif choose == '笔记薄':
                self.Notebook()
        send("pass")

        menubar = tk.Menu ( self.root)


        menubar.add_command ( label="回到菜单" , command=self.back)
        menubar.add_command (label="关于软件", command=Show)

        listbox = tk.Menu(self.root,tearoff=0)
        menubar.add_cascade(label='更多选项⬇', menu=listbox)
        #  在`文件`中加入`新建`的小菜单,即我们平时看到的下拉菜单,每一个小菜单对应命令操作。
        #  如果点击这些单元, 就会触发`do_job`的功能
        listbox.add_command(label='导入与导出', command=self.Make)
        listbox.add_command(label="我的目标", command=self.aim)

        self.root.config ( menu=menubar )


        # filemenu.add_command(label='', command=do_job)
        PZ1 = tk.Label(self.root)


        PZ1.place(rely=0,relx=0,relwidth=1,relheight=1)
        ListZhiShi = tk.Listbox(self.root)
        List = ["考试","退出","设置",'查看错题',"专题测试",'实力','笔记薄']
        title = tk.Label(self.root,text="更多考试")
        title.place(relx=0.7
                    ,rely=0.065
                    )
        def CuoTi():
            try:
                self.tk(self.tool.Cuoti())
            except:
                self.back()
                msg.showinfo('Tip',"没有错题!!")
        remove_use = tk.Button(self.root,text="错题考试\n错题做一遍",command=CuoTi)
        remove_use.place(relx=0.65,rely=0.25)

        # return_button = tk.Button(self.root,text="更新题库",command=Update)
        # return_button.place(relx=0.7,rely=0.45)
        try:
            with open('data2.json','r') as f:
                json.load(f)
        except Exception as e:
            List.append('账号更新')
            print(e)
        for i in List:
            ListZhiShi.insert(1,i)
        ListZhiShi.place(relx=0,rely=0)
        B = tk.Label(self.root,text="请选择你要参加的模式")
        B.place()
        ListZhiShi.bind("<Double-Button-1>",get)
    def Make(self):
        '''试卷生成'''
        send("pass")
        self.root.geometry('500x500')
        PZ1 = tk.Label(self.root)
        PZ1.place(rely=0, relx=0, relwidth=1, relheight=1)
        Jichu = self.tool.read_TiKu_type(type='计算机基础(文化)', modle="F")
        Jichu += self.tool.read_TiKu_type(type='计算机基础(文化)', modle="F")
        Jichu += self.tool.read_TiKu_type(type='计算机基础(办公)', modle="F")
        WangLuo = self.tool.read_TiKu_type(type='计算机网络', modle="F")
        SQL = self.tool.read_TiKu_type(type="数据库", modle="F")
        v1 = tk.IntVar() # 基础
        v2 = tk.IntVar() # 网络
        v3 = tk.IntVar() # Access
        L1 = tk.Label(text="计算机基础:(单位:道))")
        L1.grid(row=3,column=0)
        S1 = tk.Scale(self.root,
                      from_=0,  # 设置最小值
                      to=len(Jichu),  # 设置最大值
                      orient=tk.HORIZONTAL,  # 设置横向
                      resolution=1,  # 设置步长
                      # tickinterval=int(len(Jichu)/100),  # 设置刻度
                      length=240,  # 设置像素
                      variable=v1)  # 绑定变量
        S1.grid(row=3,column=1)

        L2 = tk.Label(text="计算机网络:(单位:道))")
        L2.grid(row=1,column=0)
        S2 = tk.Scale(self.root,
                      from_=0,  # 设置最小值
                      to=len(WangLuo),  # 设置最大值
                      orient=tk.HORIZONTAL,  # 设置横向
                      resolution=1,  # 设置步长
                      # tickinterval=int(len(WangLuo)/100),  # 设置刻度
                      length=240,  # 设置像素
                      variable=v2)  # 绑定变量
        S2.grid(row=1,column=1)

        L3 = tk.Label(text="计算机数据库:(单位:道))")
        L3.grid(row=2,column=0)
        S3 = tk.Scale(self.root,
                      from_=0,  # 设置最小值
                      to=len(SQL),  # 设置最大值
                      orient=tk.HORIZONTAL,  # 设置横向
                      resolution=1,  # 设置步长
                      # tickinterval=int(len(SQL)/100),  # 设置刻度
                      length=240,  # 设置像素
                      variable=v3)  # 绑定变量
        S3.grid(row=2,column=1)
        tk.Label(text="请输入生成试卷的名称:").grid(row=0,column=0)
        Name = tk.Entry(show=None)
        Name.grid(row=0,column=1)

        def main():
            name = Name.get()
            if name == '':
                msg.showinfo("Tip",'请输入试卷的考试题目')
                return
            doc = docx.Document()
            title_ = doc.add_heading(level=0)            # 设置标题
            title_.alignment = WD_ALIGN_PARAGRAPH.CENTER            # 标题居中
            title_run = title_.add_run(name)            # 添加标题内容
            title_run.font.size = Pt(14)# 设置标题字体大小
            title_run.font.name = 'Times New Roman'# 设置标题西文字体
            title_run.element.rPr.rFonts.set(qn('w:eastAsia'), '微软雅黑')# 设置标题中文字体
            # +  --> [1,2,3] + [2,3,4] = [1,2,3,2,3,4]
            # print(Jichu)
            STR = '一、单选、判断题\n'
            Num = 1
            int_JC,int_WL,int_SJK = 0,0,0


            while int_JC != v1.get(): # 计算机基础
                '''单选+判断'''
                print("基础题共找到:%s个,正在匹配%s个..." % (len(Jichu),int_JC+1))
                ran_num = random.randint(0,len(Jichu)-1)
                # print(ran_num)
                i = Jichu[ran_num]
                while 1:
                    if len(i[5]) <= 1: # 去单项选择题
                        STR += '%s.%s\nA.%s\nB.%s\nC.%s\nD.%s\n\n'%(Num,i[0],i[1],i[2],i[3],i[4])
                        break
                    else:
                        ran_num = random.randint(0, len(Jichu)-1)
                        i = Jichu[ran_num]

                Num += 1
                int_JC += 1
            while int_WL != v2.get(): #计算机网络
                '''单选+判断'''
                print("网络题共找到:%s个,正在匹配%s个..." % (len(WangLuo),int_JC+1))
                ran_num = random.randint(0,len(WangLuo)-1)
                # print(ran_num)
                i = WangLuo[ran_num]
                while 1:
                    if len(i[5]) <= 1: # 去单项选择题
                        STR += '%s.%s\nA.%s\nB.%s\nC.%s\nD.%s\n\n'%(Num,i[0],i[1],i[2],i[3],i[4])
                        break
                    else:
                        ran_num = random.randint(0, len(WangLuo)-1)
                        i = WangLuo[ran_num]

                Num += 1
                int_WL += 1
            while int_SJK != v3.get(): #数据库
                '''单选+判断'''
                print("数据库题共找到:%s个,正在匹配%s个..." % (len(WangLuo),int_JC+1))
                ran_num = random.randint(0,len(SQL)-1)
                # print(ran_num)
                i = SQL[ran_num]
                while 1:
                    if len(i[5]) <= 1: # 去单项选择题
                        STR += '%s.%s\nA.%s\nB.%s\nC.%s\nD.%s\n\n'%(Num,i[0],i[1],i[2],i[3],i[4])
                        break
                    else:
                        ran_num = random.randit(0, len(SQL)-1)
                        i = SQL[ran_num]

                Num += 1
                int_SJK += 1
            # print(STR)
            doc.add_paragraph(STR)

            # def selectPath():
            #     path_ = askdirectory()
            #     path.set(path_)
            path = filedialog.asksaveasfilename(title=u'导出路径',filetypes=[("word文件",".docx")])
            # print(path)
            doc.save(path+".docx")
        def sce():
            # try:
            All = []
            All += random.sample(Jichu,v1.get())
            All += random.sample(WangLuo,v2.get())
            All += random.sample(WangLuo,v3.get())
            path = filedialog.asksaveasfilename(title=u'导出路径', filetypes=[("sce文件", ".sce")])
            if path == '':
                print("...")
                return
            with open(path+".sce",'wb') as f:
                pickle.dump(All,f)

            msg.showinfo("Tip",'已成功保存,你可以在导入考试中,通过文件路径载入该文件来进行考试哟~~')
        # except ValueError as f:
        #     msg.showinfo("Tip",'题库现在还没有这么多题\n错误代码:%s'%(f))
        tk.Button(text="导出为\nword文档",command=main).grid(row=4,column=0)
        tk.Button(text="导出为\nsce文件",command=sce).grid(row=4,column=1)
        tk.Button(text="导入sce\n开始考试",command=self.sceKS).grid(row=6,column=0)

    def sceKS(self):
        # msg.showwarning("Tip",'研发中...')
        # return

        while 1:
            sce = filedialog.askopenfilename(title=u'sce文件路径',filetypes=[("sce文件", ".sce")])
            try:
                with open(sce,'rb') as f:
                    dict_list = pickle.load(f)
                    print(dict_list)
                    break
            except Exception as e:
                if sce == '':
                    return
                else:
                    msg.showinfo("Tip",'sce文件出现错误,错误代码:\n%s'%(e))
                    return
        # send("Yes")  # 开启防作弊
        self.tk(dict_list)

    def tk(self,list):
        send("Yes")
        self.root.title("考试中..")
        self.indexa = 0
        self.FenShu = 0
        # 初始化
        self.root.geometry("400x400")
        if self.geometry == True:
            self.root.geometry("400x400")
            self.geometry = False
        if self.c == 0:
            msg.showinfo("Tips", "由于宽度限制,用户可以自行调整其宽度")
            self.c = 12
        self.start_time = time()
        def tk_one(hei):
            try:
                que = list[self.indexa][0]
            except IndexError:
                msg.showinfo("Tip",'考试完成,你的得分:%s'%(self.FenShu))
                self.showresult(self.FenShu,many=hei)
                return
            self.root.resizable(True,False)
            A  = list[self.indexa][1]
            B = list[self.indexa][2]
            C  = list[self.indexa][3]
            D = list[self.indexa][4]
            key = list[self.indexa][5]
            type2  = list[self.indexa][6]
            tk.Label().place(relwidth=1,relheight=1)
            # print("问题:%s,\nA:%s\nB:%s\nC:%s\nD:%s\nkey:%s"%(que,A,B,C,D,key))
            Que_text = tk.Text()
            Que_text.insert ( 'end' , que )
            Que_text.place(relx=0.15, rely=0.1, relwidth=0.7, relheight=0.2)
            def Check(answer):
                if answer == key:
                    if hei == 0:
                        msg.showinfo("Tip", "该sce文件题目数为0")
                        self.back()
                        return
                    self.dict["正确率"] += 5
                    self.save()
                    Fen = int(100/hei)
                    self.Add(mode=1,type_que=type2)
                    self.FenShu += Fen
                else:
                    try:
                        self.dict["正确率"] -= 5
                        self.save()
                        self.Error.append([que,A,B,C,D,key,answer,type2])
                    except IndexError:
                        msg.showinfo("Tip","考试完成")
                tk_one(hei)
            def A_F():
                self.indexa += 1
                Check("A")
            def B_F():
                self.indexa += 1
                Check("B")
            def C_F():
                self.indexa += 1
                Check("C")
            def D_F():
                self.indexa += 1
                Check("D")
            def Check_result():
                pass
            if len(key) == 1:
                A_B = tk.Button(self.root, command=A_F, text="A.%s" % (A))
                A_B.place(relx=0.15, rely=0.3)
                B_B = tk.Button(self.root, command=B_F, text="B.%s" % (B))
                B_B.place(relx=0.15, rely=0.4)
                C_B = tk.Button(self.root, command=C_F, text="C.%s" % (C))
                C_B.place(relx=0.15, rely=0.5)
                D_B = tk.Button(self.root, command=D_F, text="D.%s" % (D))
                D_B.place(relx=0.15, rely=0.6)
            else:
                def Check_result():
                    self.indexa += 1
                    if vara.get() == 1:
                        self.Check_List.append("A")
                    if varb.get() == 1:
                        self.Check_List.append("B")
                    if varc.get() == 1:
                        self.Check_List.append("C")
                    if vard.get() == 1:
                        self.Check_List.append("D")
                    result = ''
                    for i in self.Check_List:
                        result += i
                    Check(result)
                    # print(result)
                    self.Error.append([que,A,B,C,D,key,result,type2])
                    self.count += 1
                    if self.count == hei:
                        self.showresult(self.FenShu)
                    else:
                        tk_one(hei)

                vara = tk.IntVar()
                varb = tk.IntVar()
                varc = tk.IntVar()
                vard = tk.IntVar()
                self.Check_List = []
                A_B = tk.Checkbutton(self.root, variable=vara, text="A.%s" % (A), onvalue=1, offvalue=0)
                A_B.place(relx=0.15, rely=0.3)
                B_B = tk.Checkbutton(self.root, variable=varb, text="B.%s" % (B), onvalue=1, offvalue=0)
                B_B.place(relx=0.15, rely=0.4)
                C_B = tk.Checkbutton(self.root, variable=varc, text="C.%s" % (C), onvalue=1, offvalue=0)
                C_B.place(relx=0.15, rely=0.5)
                D_B = tk.Checkbutton(self.root, variable=vard, text="D.%s" % (D), onvalue=1, offvalue=0)
                D_B.place(relx=0.15, rely=0.6)
                result = tk.Button(self.root, text="提交", command=Check_result)
                result.place(relx=0.15, rely=0.7)
        tk_one(len(list))

    def showresult (self,mark,many="j"):
        '''考试结束的收尾'''
        if many == 'j':
            many = self.All

        # 时间加分
        send("pass")
        self.end_time = time()
        resu = self.end_time - self.start_time  # 答题总用时
        # print(resu)
        avg = int(resu / self.All)
        self.dict['速度'] += 10 - avg  # 得分
        print(self.dict)
        self.save()

        # 错题保存
        def S_B():

            self.tool.write_TiKu(self.Error)
            msg.showinfo("成功","成功添加了错题")
            self.back()

            self.hreat = 0
            self.mark = 0
            self.count = 0
            self.Error = []  # 存储错的题
            self.root.geometry ( "250x250" )



        PZ1 = tk.Label(self.root)
        PZ1.place(rely=0,relx=0,relwidth=1,relheight=1)
        self.geometry = True

        show = tk.Label(self.root,text="总分:%s分,您的得分:%s"%(100,int(mark)))
        show.place(relx=0.3,rely=0.3)
        Back = tk.Button(self.root,text="将错题添加到我的错题本上",command=S_B)
        Back.place(relx=0.35,rely=0.5)

        msg.showinfo("完成","做完题要记得查漏补缺哟")

    def save(self):
        '''保存雷达图数据'''
        with open("data2.json",'w') as f:
            json.dump(self.dict,f)

    def LeiDa(self):
        plt.rcParams['font.sans-serif'] = 'SimHei'
        plt.rcParams['axes.unicode_minus'] = False
        plt.style.use('ggplot')
        def Name(L,N):
            if L<20:
                N += "\nD"
            elif L < 40:
                N += "\nC"
            elif L < 70:
                N += '\nB'
            elif L<100:
                N += "\nA"
            elif L<200:
                N += "\nS"
            elif L<400:
                N += "\nSS"
            elif L<800:
                N += "\nSSS"
            return N
        a = Name(self.dict["计算机基础"],"计算机基础")
        b = Name(self.dict["计算机网络"],"计算机网络")
        c = Name(self.dict["计算机数据库"],"计算机数据库")
        d = Name(self.dict["速度"],"速度")
        e = Name(self.dict['正确率'],'正确率')
        values = [self.dict["计算机基础"],self.dict["计算机网络"],self.dict["计算机数据库"],self.dict["速度"],self.dict['正确率']]
        feature = [a,b,c,d,e]
        angles = np.linspace(0, 2 * np.pi, len(values), endpoint=False)
        values = np.concatenate((values, [values[0]]))
        angles = np.concatenate((angles, [angles[0]]))
        fig = plt.figure()
        ax = fig.add_subplot(111, polar=True)
        ax.plot(angles, values, 'o-', linewidth=2)
        ax.fill(angles, values, alpha=0.25)
        ax.set_thetagrids(angles * 180 / np.pi, feature)
        ax.set_ylim(0,400)
        plt.title('%sの实力表格'%(self.Username))
        ax.grid(True)
        ax.tick_params('y', labelleft=False)
        from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk
        Myresult = tk.Tk()
        Myresult.title('%sの实力一览'%(self.Username))
        Can = FigureCanvasTkAgg(fig,Myresult)
        Can.draw()
        Can.get_tk_widget().grid(row=1,column=0)
        result = self.dict["计算机基础"]+self.dict["计算机网络"]+self.dict["计算机数据库"]+self.dict["速度"]+self.dict['正确率']

        Myresult.mainloop()
    def KaoShi( self ):
        list = self.tool.read_TiKu_type(modle="F")
        print(list)
        list = random.sample(list,self.All)
        self.tk(list)


def Show():
    msg.showinfo("Tip","\n制作员名单:刘博源\nQQ:3536429078,Bilibili:青空石\n\n更新记录V1.58:\n1.新增笔记本功能\n2.错题查看UI更改,并增加错题重做功能"
                       "\n3.将我的目标功能移植更多选项中")


def update():
    try:
        with open("data2.json",'r') as f:
            a = json.load(f)
        msg.showwarning("Tip","你的账号无需更新")
    except:
        with open("data2.json",'w') as f:
            json.dump({'速度':0,'正确率':0,
                       '计算机基础':0,'计算机网络':0,'计算机数据库':0},f)

        msg.showinfo("Tip","更新完毕")


class Login(): # 登陆对象

    def __init__(self):
        self.frist = True
        self.count = 0
        self.win = tk.Tk()
        self.win.title("刷题宝-登录")
        self.tool = Caozuo()
        # 读取base64转码后的数据,并设置压缩图标
        path = os.getcwd()
        ico = path + '/main.ico'
        self.win.wm_iconbitmap(ico)


        self.PZ1 = tk.Label()
        self.PZ1.place(rely=0,relx=0,relwidth=1,relheight=1)

        self.LabelUser = tk.Label(text="账号")
        self.LabelUser.place ( relx=0.15 , rely=0.1 )

        self.LabelPassWord = tk.Label ( text="密码" )
        self.LabelPassWord.place ( relx=0.15 , rely=0.3 )
        self.EntryUser = tk.Entry(show=None)
        self.EntryUser.place(relx=0.27,rely=0.1)

        self.EntryPas = tk.Entry(show="*")
        self.EntryPas.place(relx=0.27,rely=0.3)

        self.win.resizable(False,False)
        self.Wra = tk.Label(fg='red')
        self.ButtonLogon = tk.Button(text="注册",command=self.Logon,width=4)
        self.ButtonLogon.place(relx=0.27,rely=0.5)
        self.ButtonLogin = tk.Button(text="登录",command=self.Login,width=4)
        self.ButtonLogin.place(relx=0.5,rely=0.5)
        self.win.bind("<Return>",self.Reture)

        self.win.geometry("250x250")
        self.win.mainloop()
        # sys.exit()
        quit()
    def Reture(self,event
               ):
        if self.EntryPas.get() == None:
            msg.showwarning("Tip","密码没有输入")
        else:
            self.Login()
    def Login( self ):
        global UserNameFu
        with open("pass.json",'r') as F:
            st = json.load(F)
        User = self.EntryUser.get()
        if User not in st:
            msg.showinfo("错误","用户不存在")
        elif st[User] != self.EntryPas.get():
            msg.showinfo("错误","密码错误")
        else:
            self.win.destroy()# 结束时代
            UserNameFu = User
            C = Windows() # 开启新时代
    def Logon( self ):
        self.win.title ( "刷分宝--注册" )

        PZ1 = tk.Label ( )
        PZ1.place ( rely=0 , relx=0 , relwidth=1 , relheight=1 )
        LabelUser = tk.Label ( text="账号" )
        LabelUser.place ( relx=0.15 , rely=0.1 )
        LabelPassWord = tk.Label ( text="密码" )
        LabelPassWord.place ( relx=0.15 , rely=0.3 )
        EntryPas_logon = tk.Entry ( show="*" )
        EntryUser = tk.Entry ( show=None )
        EntryUser.place(relx=0.27 , rely=0.1 )
        EntryPas_logon.place ( relx=0.27 , rely=0.3 )

            # 保存窗口大小
            # 保存窗口大小

        def New ():
            self.win.title("刷分宝--注册")
            with open ( "pass.json" , 'r' ) as f:
                st = json.load ( f )

            if EntryPas_logon.get ( ) in st:
                msg.showinfo ("错误", "已有该用户,若忘记密码,你需要重新注册一个新的账号" )
            elif EntryPas_logon.get() == '' or EntryUser.get() == '':
                msg.showinfo("错误","没有输入密码账号")

            else:

                with open ( "pass.json" , "w" ) as f:
                    User = EntryUser.get()

                    passWord = EntryPas_logon.get()
                    st[User]=passWord
                    json.dump(st,f)
                try:
                    os.mkdir(User)
                except:
                    print('文件创建失败')
                with open("./%s/data1.json"%(User),'w') as f:
                    json.dump(0,f)
                with open("./%s/data2.json"%(User),'w') as f:
                    json.dump({'速度': 0, '正确率': 0,
                               '计算机基础': 0, '计算机网络': 0, '计算机数据库': 0}, f)
                    print("已为你创建了基本文件")
                    import openpyxl
                    wb = openpyxl.Workbook ( )
                    ws = wb.active
                    ws.title = "错题集"
                    wb.save("./%s/错题集.xlsx"%(User))

                    wb = load_workbook ( filename="./%s/错题集.xlsx"%(User) )
                    ws = wb["错题集"]
                    ws["A1"] = "题干"
                    ws["B1"] = 'A选项'
                    ws["C1"] = 'B选项'
                    ws["D1"] = "C选项"
                    ws["E1"] = "D选项"
                    ws["F1"] = "正确答案"
                    ws["G1"] = "你的答案"
                    msg.showinfo("成功","欢迎用户使用!!")
                    Sure.destroy()
                    EntryPas_logon.destroy()
                    EntryUser.destroy()
                    LabelPassWord.destroy()
                    LabelUser.destroy()
                    PZ1.destroy()
                    Return.destroy()
                    self.win.title ( "刷分宝--登录" )

        def Quit():
            self.win.title ( "刷分宝--登录" )
            Sure.destroy ( )
            EntryPas_logon.destroy ( )
            EntryUser.destroy ( )
            LabelPassWord.destroy ( )
            LabelUser.destroy ( )
            Return.destroy()
            PZ1.destroy ( )
        Sure = tk.Button(text="确定",command=New)
        Sure.place(relx=0.5,rely=0.5)

        Return = tk.Button(text="返回",command=Quit)
        Return.place(relx=0.2,rely=0.5)
if __name__ == '__main__':
    pid_F = os.getpid()
    with open("pid.data",'wb') as f:
        pickle.dump(pid_F,f)
    win = tk.Tk()
    with open("./DPI.data", 'wb') as f:
        pickle.dump([win.winfo_screenwidth(),win.winfo_screenheight()], f)  # [1920,1080]
    print("写入成功")
    win.destroy()
    send("No")
    poola = Pool(2)
    poola.apply_async(JianDu().Main)# 启动考试防作弊进程
    Main_Object = Login()
    send('close')

功能

  1. 选择与判断为主的考试 (代码详见Window类的tk()函数)
  2. 考试的作弊检测(主要是考试切换的检测(代码详见JianDu类))
  3. 用户的建立(代码详见Login)
  4. 错题的查看(代码详见window类的Worre模块)
  5. 根据用户的考试情况生成错题(代码详见window类的showresult 模块)
  6. 生成docx试卷,可以用于纸质考试使用
  7. sce文件生成,可以根据sce考试,且题目为固定的内容
  8. 6、7 的 试卷考试的题目数目可以自定义
  9. 笔记本的建立(详见Window类的Notwpad模块)
  10. 目标的建立(类似成就)

下载链接

	由于该python程序有大量的IO编程,所以必要的文件需要建立,所以在这里立下链接,以便下载:
	目前的版本:1.58(如果有更新那么我会提示的)
	
  	百度云:
	     链接:https://pan.baidu.com/s/1TqUXtCNwd5Xw2qYJIgsnLw 
	     提取码:o7dr
	CSDN:
		https://download.csdn.net/download/tc9527_/12142081
	码云与GitHub暂无

不同版本的用户迁移(从1.58版本开始)

选择
所有用户名文件
AL文件与ALL文件
pass.json文件
错题集.xlsx
题库
复制或移动
至新版的文件夹下

Linux的使用

暂时无法支持Liunx使用
;