有没有办法删除tkinter中的整个单词?
代码如下:
from tkinter import *
root = Tk()
def delete_whole_word(event):
# Code to delete a whole word
pass
text = Text(root, width = 65 , height = 20 , font = "consolas 14")
text.grid(row = 0 , column = 0)
text.insert(1.0 , "This is a text widget")
text.mark_set(INSERT , END)
text.bind("<BackSpace>" , delete_whole_word)
mainloop()在这里,当我按下BackSpace键时,我想删除整个单词,而不是只删除一个字符。
删除一个完整的单词,我的意思是:

在tkinter中有什么方法可以做到这一点吗?
如果有人能帮我,那就太好了。
发布于 2021-01-29 14:08:48
使用:
def delete_whole_word(event):
text.delete("insert-1c wordstart", "insert")
return "break"https://stackoverflow.com/questions/65949356
复制相似问题