Tk Source Code

View Ticket
Login
Ticket UUID: 3609608
Title: Windows Text hi-lights disappear when text loses focus
Type: Bug Version: obsolete: 8.5.13
Submitter: rovitotv Created on: 2013-03-31 17:26:06
Subsystem: 18. [text] Assigned To: fvogel
Priority: 6 Severity: Minor
Status: Closed Last Modified: 2015-10-03 14:14:37
Resolution: Invalid Closed By: fvogel
    Closed on: 2015-10-03 14:14:37
Description:
On Windows the text widget hi-lights will disappear when text widget loses focus.  Linux and Mac OS X Tk behaves appropriately.  This bug is generated from a number of bugs for IDLE (Python's IDE) here http://bugs.python.org/issue14146.  On Windows the IDLE debugger no longer hi-lights the current line in the editor.  On Windows the find/replace functions are not functioning properly because found text is not hi-lighted.  The issue was tested using Tk 8.5.13 and Tk 8.6 both exhibit the same problem.  We created a small test program to reproduce this bug with Python 3.x and tkinter:

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()

Thanks for your help!
User Comments: fvogel added on 2015-10-01 19:37:58:
As stated by Mark Roseman below, using -inactiveselectbackground option allows to control the behaviour of the selected text when the text widget does not have focus.

I suggest closure of this ticket with Resolution = Invalid

roseman added on 2015-08-31 19:09:37:
This can be fixed by using the "inactiveselectbackground" option for text widgets. Not sure if it's correct that this defaults to empty on win32 or not...

rovitotv added on 2013-04-01 01:05:11:
I should add the find/replace dialog issue with IDLE is here:
http://bugs.python.org/issue17511