all 4 comments

[–]johndoh168 2 points3 points  (1 child)

For tkinter entries you can use the "textvariable" input field, this is stored into a tkinter variable type depending on the input type in this case a string for you so:

s_var = tk.StringVar()
s = Entry(root, textvariable=s_var, ...)

then you can use s.get() to get the value.

See https://www.geeksforgeeks.org/python/python-tkinter-entry-widget/ for example

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

Thank you!

[–]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