Python3(Tkinter) highlight text on focus Python3(Tkinter) highlight text on focus tkinter tkinter

Python3(Tkinter) highlight text on focus


If I understand the question you want to use the method select_range. This selects the characters of text ready to replace, delete or copy. It's included in a callback function to <FocusIn>

import tkinter as tkdef select_on_focus(event):    event.widget.select_range(0, tk.END) # Select all the text in the widget.root = tk.Tk()ent = tk.Entry(root)ent.grid()ent.focus_set()ent.insert(0, 'abcde')ent.bind('<FocusIn>', select_on_focus)root.mainloop()