1

I want to get the text from this, How do I get it? I've instaled tkniter, customtkinter but idk how to get the text from this

entry1=customtkinter.CTkEntry(master=frame, width=220, placeholder_text='Username')

  • Does this answer your question? [Why is Tkinter Entry's get function returning nothing?](https://stackoverflow.com/questions/10727131/why-is-tkinter-entrys-get-function-returning-nothing) – Collaxd Jan 24 '23 at 15:59

1 Answers1

0

Looking into the source code for customtkinter, it seems like you can bind a customtkinter.StringVar() to the entry's textvariable and call get() on that variable

# instantiate a StringVar to store the entry contents
entry1_var = customtkinter.StringVar(value='Test')
# instantiate the entry widget
entry1 = customtkinter.CTkEntry(
    master=frame,
    width=220,
    placeholder_text='Username',
    # bind the variable to this widget
    textvariable=entry1_var,
)
entry1.pack()
print(entry1_var.get())
# => Test

However, you should also be able to call get() directly on the CTkEntry widget itself without having to worry about instantiating / binding to textvariable

entry1.get()
JRiggles
  • 4,847
  • 1
  • 12
  • 27