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')
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')
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()