I have a tkinter project and need the text, I put it in the Entry box, printed it in the console. but when I use get() I get empty space in the console.
this is my interface. when I put 1234 I could place it above when I click the button "Pull record data" but I need that number in my console. to use that entry for other things. but when I try to print it I get nothing in the console like this:
root = tk.Tk() root.geometry("390x500") root.title("Airtable Project Tracker")
str = tk.StringVar(root)
str.set('ie. recveGd8w9ukxLkk9')
tk.Label(root, textvariable=str).pack()
recid = tk.Entry(root, width=50)
recid.pack(pady = 10)
print(recid.get())
id_button = tk.Button(root, text="Pull record data", width=50, command = lambda:str.set(recid.get()))
id_button.pack(pady = 5)
recide
is an obejckt, if you create it you can pass the parameter textvariable
to acces the value.
text = tk.StringVar()
recide = tk.Entry(root, width=50, textvariable=text)
You can access the variable with text.get()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.