How to access Entry field value in root window from Toplevel window?
As noted by Menno above, adjusting the window 2 function to pass email_box.get()
allows the value to be passed between the windows.
First file code:
from tkinter import *
from elt2 import window2
root = Tk()
email_box = Entry(root, width=35, borderwidth=2)
email_box.grid(row=0, column=1, pady=(5, 0), padx=10)
pass_box = Entry(root, width=35, borderwidth=2)
pass_box.grid(row=1, column=1)
def submitpass():
if pass_box.get() == "test":
passshow = Label(root, text=" CORRECT ", background="#2E0063", fg='white')
passshow.grid(row=3, column=0, columnspan=2, padx=8)
window2(email_box.get())
else:
passshow = Label(root, text="INCORRECT", background="#2E0063", fg='white')
passshow.grid(row=3, column=0, columnspan=2, padx=8)
checkbtn = Button(root, text="CHECK", command=submitpass)
checkbtn.grid(row=2, column=1, columnspan=2, padx=10, pady=5, ipadx=45)
root.mainloop()
Second file code:
from tkinter import *
def window2(entry_value):
root2 = Toplevel()
root2.geometry("250x75")
entry_take = Entry(root2)
entry_take.insert(0, entry_value)
entry_take.pack()
root2.mainloop()