Skip to content

Instantly share code, notes, and snippets.

@vigilantPotato
Created April 9, 2024 21:35
Show Gist options
  • Save vigilantPotato/1d53b3644c8fdd34e0ca4727b735bd48 to your computer and use it in GitHub Desktop.
Save vigilantPotato/1d53b3644c8fdd34e0ca4727b735bd48 to your computer and use it in GitHub Desktop.
How to get the text in entry widget
import ctypes
import tkinter
def get_entry_text():
b["text"] = e1.get() #set label text
e1.delete(0, tkinter.END) #delete entry
if __name__ == "__main__":
ctypes.windll.shcore.SetProcessDpiAwareness(1)
root = tkinter.Tk()
#Entry
e1 = tkinter.Entry(root, bd=5)
e1.pack(padx=3, pady=3)
#Button
b = tkinter.Button(
root,
width = 15,
bg = "lightblue",
text = "get entry",
command = get_entry_text
)
b.pack(pady=3)
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment