I am working in code that calculates the corrosion rate with Python and Tkinter pour the graphic part. My calculator has two pages: login page and calculator page. I want to save my last execution of the code so I will work with pickle to save my function login (redirect the users to the calculator page) the problem is that I don't know in which part of the program I should pickle the function and in which will be unpickling.
this is part of my program:
def login():
#################################################page de connexion#########################################################################################################################################################################################################################################################################################################################################################################################################################
interface = Tk()
interface.title("login page")
interface.iconbitmap("veritas.ico")
interface.configure(background="sienna")
w, h = interface.winfo_screenwidth(), interface.winfo_screenheight()
interface.geometry("%dx%d" % (w, h))
bg= PhotoImage(file = "bv.png")
bv = ImageTk.PhotoImage((Image.open("bureau_veritas.png")).resize((60, 80)))
aix_marseille= ImageTk.PhotoImage((Image.open("marseille.png")).resize((75, 60)))
labelA= Label(interface, image = bg)
labelA.place(x=350, y=150)
label2= Label(interface, text='Welcome to CR software', font=("Showcard Gothic", 30), bg="sienna", fg="black")
label2.place(x=410, y=10)
label3= Label(interface, text='the user of the software should entre his name and the code of security !', font=("time", 15), bg="sienna", fg="white")
label3.place(x=330, y=100)
label4= Label(interface, image = bv)
label4.place(x=0, y=0)
label5= Label(interface, image = aix_marseille)
label5.place(x=1200, y=0)
name = Label(interface, text='name:', font=("Arial", 13))
name.place(x=500, y=230)
user_name = StringVar()
name_entry= Entry(interface, textvariable=user_name)
name_entry.insert(0, "Name")
name_entry.place(x=600, y=230)
code = Label(interface, text='code:', font=("Arial", 13))
code.place(x=500, y=280)
user_code = StringVar()
code_entry= Entry(interface, textvariable=user_code, show="*")
code_entry.insert(0, "****")
code_entry.place(x=600, y=280)
def add():
top=Toplevel(interface)
top.title("sign in page")
top.iconbitmap("veritas.ico")
top.geometry("300x250")
label1= Label(top, text="the user informations", font=("time", 15))
label1.pack()
label2= Label(top, text="please entre the user name", font=("time", 10))
label2.pack()
name= StringVar()
name_label= Entry(top, textvariable=name)
name_label.insert(0, "name")
name_label.pack()
label3= Label(top, text="Entre the user secret code", font=("time", 10))
label3.pack()
code_entry= StringVar()
code_entry= Entry(top, textvariable=code_entry, show="*")
code_entry.insert(0, "****")
code_entry.pack()
def submit():
name=name_label.get()
code=code_entry.get()
count = cur.execute("INSERT INTO USERS (name, mdp) VALUES (?,?)",(name, code))
conn.commit()
bouton_searche= Button(top, text='submit', font=("SimSun", 15),command=submit)
bouton_searche.pack()
bouton_add = Button(interface, text='ADD USER', font=("Terminal", 15), width=10,command=add)
bouton_add.place(x=770, y=570)
bouton_login = Button(interface, text='LOGIN', font=("Terminal", 15), width=10, command=login)
bouton_login.place(x=370, y=570)
interface.mainloop()