How to make a Select All function for tkinter ScrolledText
15:22 16 Aug 2026
from tkinter import scrolledtext, Tk, Button
 
def copy():
    try:
        txt = text.get('sel.first', 'sel.last')
        window.clipboard_append(txt)
    except tk.TclError:
        pass
 
window = Tk()
 
text = scrolledtext.ScrolledText(window)
text.pack()
 
button = Button(window, text="Copy", command=copy)
button.pack()

window.mainloop()

I'm making a Notepad application and I want a function to select the all the text in the widget. I already made a Copy function (see code above). How can I make the Select All function?

python selectall tkinter-scrolledtext