Text Doesn't Contain Any Characters Tagged With "sel" Tkinter
I recently read on of the answers written by respected Bryan Oakley(Tkinter adding line number to text widget) where he showed a sample code about solving the problem. When I tried
Solution 1:
The problem is when you try to copy or delete non-selected text you're getting error. Solution would be to add few extra tests. Replace yours _proxy
function with mine to get a working result.
def _proxy(self, command, *args):
# avoid error when copying
if command == 'get' and (args[0] == 'sel.first' and args[1] == 'sel.last') and not textArea.tag_ranges('sel'): return
# avoid error when deleting
if command == 'delete' and (args[0] == 'sel.first' and args[1] == 'sel.last') and not textArea.tag_ranges('sel'): return
cmd = (self._orig, command) + args
result = self.tk.call(cmd)
if command in ('insert', 'delete', 'replace'):
self.event_generate('<<TextModified>>')
return result
Post a Comment for "Text Doesn't Contain Any Characters Tagged With "sel" Tkinter"