0

textvarible that is created in click function for entry box is not printing any thing in function d. i.e on call to function d(), a.get() is empty. Why is this not printing?

I tried threading these two click() and d() function, but nothing works

from tkinter import *

def click():
    def d():
        print(a.get())


    w2=Tk()
    a=StringVar()
    E=Entry(w2,textvariable=a).pack()
    b=Button(w2,text="submit",command=d).pack()

w=Tk()  
b=Button(w,text="ok",command=click).pack()
mainloop()
dustinos3
  • 934
  • 3
  • 17
  • 27
Siddhant Shah
  • 63
  • 1
  • 5

1 Answers1

1

Seems to be a problem with multiple instances of Tk(). See Why are multiple instances of Tk discouraged? Instead open the second window as Toplevel():

w2 = Toplevel(w)
figbeam
  • 7,001
  • 2
  • 12
  • 18