import tkinter as tk
def on_submit():
value = entry.get()
label.config(text="You entered: " + value)
# Create the main window
root = tk.Tk()
root.title("Entry Example")
# Create an Entry widget
entry = tk.Entry(root, width=30)
entry.pack(pady=10)
# Create a button to submit the entry
submit_btn = tk.Button(root, text="Submit", command=on_submit)
submit_btn.pack()
# Create a label to display the entered value
label = tk.Label(root, text="")
label.pack(pady=10)
# Run the Tkinter event loop
root.mainloop()
Output:
Comments
Post a Comment