我试图只选择 ScrolledText 中输入的单词,但整行都被选中了。选择所有代码:
# 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')
请注意,在第二张图片中,只选择了单词的结尾,但在第一张图片中,整行都被选中了。tkinter 是否可以实现此功能?
我正在使用 python 3.6