Roger Serwy added the comment: It's definitely a "bug" with Tk. Whenever the Text widget loses focus, the selection highlighting goes away. The following example code brings up a focused text box with selected text. Clicking the button switches focus to the button itself and then back to the text widget. During that focus change, the selection highlight goes away.
from tkinter import * main = Tk() text = Text(main, width=40, height=10, wrap="char") text.pack() text.insert(INSERT, "".join(map(str, range(100)))) text.tag_add(SEL, "1.0", "end") text.focus_set() def jump(): text.after(500, btn.focus_set) text.after(1000, text.focus_set) btn = Button(main, text="Click me", command=jump) btn.pack() main.mainloop() One possible solution would be to use the "<FocusOut>" and "<FocusIn>" events to substitute the "sel" tag with a custom tag so that the highlight remains when losing focus, and then replace it with the "sel" tag when gaining focus. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue14146> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com