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

登录系统

生日系统

抽奖系统

抽奖系统1.0

抽奖系统2.0

抽奖系统3.0

练习系统

练习系统1.0

练习系统2.0

练习系统3.0

练习系统4.0

练习系统4.0 

录入判断题

        def insert():
            num=var1.get()
            question=var2.get()
            answer=var3.get()
            with open('d:\\登录系统\\%s\\练习二2.1.pickle'%(user_name),'rb') as file:
                lst1=pickle.load(file)
            with open('d:\\登录系统\\%s\\练习二2.2.pickle'%(user_name),'rb') as file:
                lst2=pickle.load(file)
            with open('d:\\登录系统\\%s\\练习二2.3.pickle'%(user_name),'rb') as file:
                lst3=pickle.load(file)
            if num not in lst1:
                lst1.append(num)
                lst2.append(question)
                lst3.append(answer)
                var4.set('录入成功')
            else:
                var4.set('录入失败')
            with open('d:\\登录系统\\%s\\练习二2.1.pickle'%(user_name),'wb') as file:
                pickle.dump(lst1,file)
                file.close()
            with open('d:\\登录系统\\%s\\练习二2.2.pickle'%(user_name),'wb') as file:
                pickle.dump(lst2,file)
                file.close()
            with open('d:\\登录系统\\%s\\练习二2.3.pickle'%(user_name),'wb') as file:
                pickle.dump(lst3,file)
                file.close()  

删除判断题 

        def delete():
            num=var1.get()
            question=var2.get()
            answer=var3.get()
            with open('d:\\登录系统\\%s\\练习二2.1.pickle'%(user_name),'rb') as file:
                lst1=pickle.load(file)
            with open('d:\\登录系统\\%s\\练习二2.2.pickle'%(user_name),'rb') as file:
                lst2=pickle.load(file)
            with open('d:\\登录系统\\%s\\练习二2.3.pickle'%(user_name),'rb') as file:
                lst3=pickle.load(file)
            if num in lst1:
                t=lst1.index(num)
                lst1.pop(t)
                lst2.pop(t)
                lst3.pop(t)
                var4.set('删除成功')
            else:
                var4.set('删除失败')
            with open('d:\\登录系统\\%s\\练习二2.1.pickle'%(user_name),'wb') as file:
                pickle.dump(lst1,file)
                file.close()
            with open('d:\\登录系统\\%s\\练习二2.2.pickle'%(user_name),'wb') as file:
                pickle.dump(lst2,file)
                file.close()
            with open('d:\\登录系统\\%s\\练习二2.3.pickle'%(user_name),'wb') as file:
                pickle.dump(lst3,file)
                file.close()  

练习系统4.0 

flag2=1
user_name='wjw'
def panduan():
    global flag2
    if flag2==1:
        root_tiankong=tk.Tk()
        root_tiankong.title('判断题')
        screenheight=root_tiankong.winfo_screenheight()
        screenwidth=root_tiankong.winfo_screenwidth()
        height=300
        width=500
        x=(screenwidth-width)//2
        y=(screenheight-height)//2
        root_tiankong.geometry('%dx%d+%d+%d'%(width,height,x,y))
        tk.Label(root_tiankong,text='判断题',font=('宋体',20),fg='red',width=10,height=2).place(x=180,y=0)
        tk.Label(root_tiankong,text='题号:',font=('宋体',12),fg='black',width=5).place(x=100,y=70)
        tk.Label(root_tiankong,text='题目:',font=('宋体',12),fg='black',width=5).place(x=100,y=120)
        tk.Label(root_tiankong,text='答案:',font=('宋体',12),fg='black',width=5).place(x=100,y=170)
        var1=tk.StringVar()
        var2=tk.StringVar()
        var3=tk.StringVar()
        var4=tk.StringVar()
        def insert():
            num=var1.get()
            question=var2.get()
            answer=var3.get()
            with open('d:\\登录系统\\%s\\练习二2.1.pickle'%(user_name),'rb') as file:
                lst1=pickle.load(file)
            with open('d:\\登录系统\\%s\\练习二2.2.pickle'%(user_name),'rb') as file:
                lst2=pickle.load(file)
            with open('d:\\登录系统\\%s\\练习二2.3.pickle'%(user_name),'rb') as file:
                lst3=pickle.load(file)
            if num not in lst1:
                lst1.append(num)
                lst2.append(question)
                lst3.append(answer)
                var4.set('录入成功')
            else:
                var4.set('录入失败')
            with open('d:\\登录系统\\%s\\练习二2.1.pickle'%(user_name),'wb') as file:
                pickle.dump(lst1,file)
                file.close()
            with open('d:\\登录系统\\%s\\练习二2.2.pickle'%(user_name),'wb') as file:
                pickle.dump(lst2,file)
                file.close()
            with open('d:\\登录系统\\%s\\练习二2.3.pickle'%(user_name),'wb') as file:
                pickle.dump(lst3,file)
                file.close() 
        def delete():
            num=var1.get()
            question=var2.get()
            answer=var3.get()
            with open('d:\\登录系统\\%s\\练习二2.1.pickle'%(user_name),'rb') as file:
                lst1=pickle.load(file)
            with open('d:\\登录系统\\%s\\练习二2.2.pickle'%(user_name),'rb') as file:
                lst2=pickle.load(file)
            with open('d:\\登录系统\\%s\\练习二2.3.pickle'%(user_name),'rb') as file:
                lst3=pickle.load(file)
            if num in lst1:
                t=lst1.index(num)
                lst1.pop(t)
                lst2.pop(t)
                lst3.pop(t)
                var4.set('删除成功')
            else:
                var4.set('删除失败')
            with open('d:\\登录系统\\%s\\练习二2.1.pickle'%(user_name),'wb') as file:
                pickle.dump(lst1,file)
                file.close()
            with open('d:\\登录系统\\%s\\练习二2.2.pickle'%(user_name),'wb') as file:
                pickle.dump(lst2,file)
                file.close()
            with open('d:\\登录系统\\%s\\练习二2.3.pickle'%(user_name),'wb') as file:
                pickle.dump(lst3,file)
                file.close() 
        tk.Entry(root_tiankong,textvariable=var1,width=30).place(x=150,y=70)
        tk.Entry(root_tiankong,textvariable=var2,width=30).place(x=150,y=120)
        tk.Entry(root_tiankong,textvariable=var3,width=30).place(x=150,y=170)
        tk.Button(root_tiankong,text='录入',font=('宋体',12),width=5,bg='red',fg='white',command=insert).place(x=200,y=210)
        tk.Button(root_tiankong,text='删除',font=('宋体',12),width=5,bg='black',fg='white',command=delete).place(x=260,y=210) 
        tk.Label(root_tiankong,textvariable=var4,font=('宋体',12),bg='white',fg='red',width=10).place(x=210,y=250)
        root_tiankong.mainloop()
    else:
        pass
panduan() 

 

你可能感兴趣的:(#,《,Tkinter,》,python,开发语言)