I'm trying to select only the entered words in a ScrolledText but the whole line is getting selected. Select all code:
# I'm using ScrolledText for the input field
self.textBox = ScrolledText.ScrolledText(master=self.topFrame, wrap="word", bg='beige', padx=20, pady=5)
# Binding Shortcuts
rootone.bind("<Control-a>", self.selectAllOperation)
# Function Defination
def selectAllOperation(self, event=None):
self.textBox.tag_add('sel', '1.0', 'end')
Note that in the second picture only end of the words are selected but in the first picture the whole line is getting selected. Is it possible in tkinter to implement this feature?
I'm using python 3.6
Instead of selecting the whole text from
1.0
toend
, you have to do it line by line fromy.0
toy.end
.Get the number of lines:
Loop all lines,
select
fromy.0
toy.end
:Tested with Python: 3.5