Created
April 9, 2024 21:35
-
-
Save vigilantPotato/1d53b3644c8fdd34e0ca4727b735bd48 to your computer and use it in GitHub Desktop.
How to get the text in entry widget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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