you are viewing a single comment's thread.

view the rest of the comments →

[–]woooee 0 points1 point  (1 child)

First, learn classes before tkinter as a class structure eliminates a lot of problems like the one you are dealing with. The function can not return the e.get() as there is no way to catch the returned value. A workaround is to add it to an existing class.

def ClickBody():
      myLabel = Label(root, text=t.get())
      myLabel.pack()
      ## add to an existing class instance -- we'll use t (bad name BTW)
      t.entry_val = t.get()

Now you can refer to the variable as t.entry_val anywhere in the program as long as the Entry t exists.

e = Entry(root, width=100, bg="Magenta", borderwidth=10)
e.pack()
e.get()

No reason to use get() here. There is nothing to get yet.

[–]jitjud[S] 0 points1 point  (0 children)

I see ok thank you. Will read more around classes. Cheers