How to Get Value From Entry On Button Click in Tkinter
In this tutorial, we are going to see how to get value from entry on button click with Tkinter in Python..
The Entry widget has a get() method to get the value entered by the user.
myEntry.get()
How to Get Value From Entry On Button Click in Tkinter
import tkinter as tk gui = tk.Tk() gui.geometry("300x100") def getEntry(): res = myEntry.get() print(res) myEntry = tk.Entry(gui, width=40) myEntry.pack(pady=20) btn = tk.Button(gui, height=1, width=10, text="Read", command=getEntry) btn.pack() gui.mainloop()
Output:
