[issue45796] Using tab to cycle through tkinter widgets breaks foreground styling

Chris Eykamp report at bugs.python.org
Fri Nov 12 16:51:34 EST 2021


New submission from Chris Eykamp <chris at eykamp.com>:

Attached is a slightly modifed example of the code sample in Bryan Oakley's response to:

https://stackoverflow.com/questions/30337351/how-can-i-ensure-my-ttk-entrys-invalid-state-isnt-cleared-when-it-loses-focus

I have modified it by changing the style.map to change the widget's foreground color (rather than background), and by adding a button below the text input.

Typing a string containing "invalid" into the textbox causes it to fail validation (its state is shown in the bottom label, updated every second).  As expected, the foreground changes to red.

However, if I use [tab] to toggle between the elements, the foreground of the text entry gets changed to black, even if the item is invalid.

Adding         
    style.map("TEntry",  selectforeground=[('invalid', "green")])
creates a new set of weirdness, where the invalid text becomes green when tabbing through the widgets.


I'm running on Windows 10, Python 3.83.

----------
components: Tkinter
files: simple.py
messages: 406242
nosy: watusimoto
priority: normal
severity: normal
status: open
title: Using tab to cycle through tkinter widgets breaks foreground styling
versions: Python 3.8
Added file: https://bugs.python.org/file50437/simple.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45796>
_______________________________________


More information about the Python-bugs-list mailing list