Python entry questions when clicked

Asked 2 years ago, Updated 2 years ago, 74 views

When I type in entry, I want to delete the existing contents when I click entry, what should I do? I know you can erase it with Entry.configure("") or with Entry.delete(0, END) I don't know how to make it work when I click. Please let me know!

python tkinter

2022-09-20 17:24

1 Answers

To summarize the question briefly

Please tell me how to add an Entry Click Event!

It's

import tkinter as tk

root = tk.Tk()
entry = tk.Entry()


def handle_click():
  //Code to erase content

entry.pack()

entry.bind("<1>", handle_click)
root.mainloop()

You can add a click event using bind.

Note: https://stackoverflow.com/questions/44160181/tkinter-call-function-when-entry-box-is-clicked


2022-09-20 17:24

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.