I am writing a program such that a user can enter his details one window and a new window comes showing the output. But, for some reason, the labels in the second window are not being printed.
from tkinter import *
window = Tk()
window.title("Login")
window.geometry("500x500")
window.resizable(0,0)
l = Label(window, text="Name: ", font="Roman 20 bold",padx=10,pady=10)
l.grid(row=0,column=0)
l = Label(window, text="Password: ", font="Roman 20 bold",padx=10,pady=10)
l.grid(row=1,column=0)
e1 = Entry(window, font="Roman 20 bold")
e1.grid(row=0,column=1)
e2 = Entry(window, font="Roman 20 bold",show="*")
e2.grid(row=1,column=1)
def test():
a= e1.get()
b= e2.get()
mess = Tk()
mess.title("Output")
mess.geometry("500x500")
mess.resizable(0,0)
m= StringVar()
m.set("Name: "+a)
l = Label(mess, textvariable=m, font="Roman 20 bold",padx=10,pady=10)
l.grid()
n= StringVar()
n.set("Password: "+b)
l = Label(mess, textvariable=n, font="Roman 20 bold",padx=10,pady=10)
l.grid(row=1,column=0)
mess.mainloop()
b = Button(window,text="Click",font="Roman 15 bold",width=15,command= test)
b.grid(row=2,column=0)
window.mainloop()
I don't think it is an issue with the get() method as I am able to print the values obtained on the Python shell screen. So, I think it might be an issue with the label(), though I might be wrong.