用Python的内置包Tkinter写一个练习系统2.0

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6

登录系统

生日系统

抽奖系统1.0

抽奖系统2.0

抽奖系统3.0

练习系统1.0

练习系统2.0

切换题目

    def insert():
        with open('d:\\登录系统\\练习一1.1.pickle','rb') as file:
            lst1=pickle.load(file)
        with open('d:\\登录系统\\练习一1.2.pickle','rb') as file:
            lst2=pickle.load(file)
        with open('d:\\登录系统\\练习一1.3.pickle','rb') as file:
            lst3=pickle.load(file)
        lst3.pop(0)
        if len(lst1)!=0:
            num=lst1.pop(0)
            var1.set(num)
            question=lst2.pop(0)
            var2.set(question)
        else:
            var1.set('ERROR')
            var2.set('ERROR')
        t.delete(1.0,tk.END)
        t.insert('end',var2.get())
        with open('d:\\登录系统\\练习一1.1.pickle','wb') as file:
            pickle.dump(lst1,file)
            file.close()
        with open('d:\\登录系统\\练习一1.2.pickle','wb') as file:
            pickle.dump(lst2,file)
            file.close()
        with open('d:\\登录系统\\练习一1.3.pickle','wb') as file:
            pickle.dump(lst3,file)
            file.close()

正确按钮

    def true():
        result='正确'
        with open('d:\\登录系统\\练习二2.3.pickle','rb') as file:
            lst3=pickle.load(file)
        if len(lst3)!=0:
            t=lst3[0]
            if t==result:
                var4.set('回答正确')
            else:
                var4.set('回答错误')
        else:
            var4.set('ERROR')
        with open('d:\\登录系统\\练习二2.3.pickle','wb') as file:
            pickle.dump(lst3,file)
            file.close()             

错误按钮

    def false():
        result='错误'
        with open('d:\\登录系统\\练习二2.3.pickle','rb') as file:
            lst3=pickle.load(file)
        if len(lst3)!=0:
            t=lst3[0]
            if t==result:
                var4.set('回答正确')
            else:
                var4.set('回答错误')
        else:
            var4.set('ERROR')
        with open('d:\\登录系统\\练习二2.3.pickle','wb') as file:
            pickle.dump(lst3,file)
            file.close()                

练习系统2.0

def lianxi2():
    def insert():
        with open('d:\\登录系统\\练习二2.1.pickle','rb') as file:
            lst1=pickle.load(file)
        with open('d:\\登录系统\\练习二2.2.pickle','rb') as file:
            lst2=pickle.load(file)
        with open('d:\\登录系统\\练习二2.3.pickle','rb') as file:
            lst3=pickle.load(file)
        lst3.pop(0)
        if len(lst1)!=0:
            num=lst1.pop(0)
            var1.set(num)
            question=lst2.pop(0)
            var2.set(question)
        else:
            var1.set('ERROR')
            var2.set('ERROR')
        t.delete(1.0,tk.END)
        t.insert('end',var2.get())
        with open('d:\\登录系统\\练习二2.1.pickle','wb') as file:
            pickle.dump(lst1,file)
            file.close()
        with open('d:\\登录系统\\练习二2.2.pickle','wb') as file:
            pickle.dump(lst2,file)
            file.close()
        with open('d:\\登录系统\\练习二2.3.pickle','wb') as file:
            pickle.dump(lst3,file)
            file.close()
    def true():
        result='正确'
        with open('d:\\登录系统\\练习二2.3.pickle','rb') as file:
            lst3=pickle.load(file)
        if len(lst3)!=0:
            t=lst3[0]
            if t==result:
                var4.set('回答正确')
            else:
                var4.set('回答错误')
        else:
            var4.set('ERROR')
        with open('d:\\登录系统\\练习二2.3.pickle','wb') as file:
            pickle.dump(lst3,file)
            file.close()            
    def false():
        result='错误'
        with open('d:\\登录系统\\练习二2.3.pickle','rb') as file:
            lst3=pickle.load(file)
        if len(lst3)!=0:
            t=lst3[0]
            if t==result:
                var4.set('回答正确')
            else:
                var4.set('回答错误')
        else:
            var4.set('ERROR')
        with open('d:\\登录系统\\练习二2.3.pickle','wb') as file:
            pickle.dump(lst3,file)
            file.close()               
    lst1=['第二题','第三题']
    lst2=['图的深度优先搜索序列和广度优先搜索序列不是唯一的。','稀疏矩阵压缩存储后必将失去随机存取功能。']
    lst3=['正确','正确','正确']
    with open('d:\\登录系统\\练习二2.1.pickle','wb') as file:
        pickle.dump(lst1,file)
        file.close()
    with open('d:\\登录系统\\练习二2.2.pickle','wb') as file:
        pickle.dump(lst2,file)
        file.close()
    with open('d:\\登录系统\\练习二2.3.pickle','wb') as file:
        pickle.dump(lst3,file)
        file.close()
    lianxi2_shuati=tk.Tk()
    lianxi2_shuati.title('练习二')
    screenheight=lianxi2_shuati.winfo_screenheight()
    screenwidth=lianxi2_shuati.winfo_screenwidth()
    height=300
    width=500
    x=(screenwidth-width)//2
    y=(screenheight-height)//2
    lianxi2_shuati.geometry('%dx%d+%d+%d'%(width,height,x,y))
    tk.Label(lianxi2_shuati,text='练习二',font=('宋体',20),width=20,height=2,fg='blue').place(x=110,y=10)
    var1=tk.StringVar()
    var2=tk.StringVar()
    var1.set("第一题")
    var2.set('AVL是一棵二叉树其树上任一结点的平衡因子的绝对值不大于1。')
    tk.Label(lianxi2_shuati,textvariable=var1,font=('宋体',12),width=10).place(x=20,y=70)
    t=tk.Text(lianxi2_shuati,width=40,height=4)
    t.place(x=120,y=70)
    t.insert('end',var2.get())
    var3=tk.StringVar()
    var4=tk.StringVar()
    tk.Button(lianxi2_shuati,text='下一题',width=8,command=insert).place(x=220,y=240)
    tk.Button(lianxi2_shuati,text='正确',font=('宋体',12),width=5,command=true).place(x=180,y=150)
    tk.Button(lianxi2_shuati,text='错误',font=('宋体',12),width=5,command=false).place(x=280,y=150)
    tk.Label(lianxi2_shuati,textvariable=var4,width=20,font=('宋体',20),fg='blue').place(x=120,y=190)
    lianxi2_shuati.mainloop()
lianxi2() 

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6
标签: python