I am making a text editor in Python and I need to add an option from the menu bar to select all text written. I tried:
def select_all(self):
self.textbox.select(ALL)
(Sorry, I'm not an advanced coder so you can expect at simple mistakes.)
CodePudding user response:
The selection is managed by a tag named "sel". To select a range of characters, add that tag to the range of text. To select all of the text, set the range to begin with the first character ("1.0") and end with the last ("end")
text = tk.Text(...)
...
text.tag_add("sel", "1.0", "end")