This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Using tab to cycle through tkinter widgets breaks foreground styling
Type: Stage: resolved
Components: Tkinter Versions: Python 3.8
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: epaine, ned.deily, serhiy.storchaka, watusimoto, watusimoto2
Priority: normal Keywords:

Created on 2021-11-12 21:51 by watusimoto, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
simple.py watusimoto, 2021-11-12 21:51 Script to reproduce problem
Messages (9)
msg406242 - (view) Author: Chris Eykamp (watusimoto) * Date: 2021-11-12 21:51
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.
msg406243 - (view) Author: Chris Eykamp (watusimoto) * Date: 2021-11-12 21:54
I'll add that when the red text incorrectly turns black, on my display, I can see a very subtle red halo, as if the text is being printed first as red, then as black in a second pass.
msg406323 - (view) Author: E. Paine (epaine) * Date: 2021-11-14 15:13
I believe this is just because the `selectbackground` is only shown when the widget has focus. Try, for example, only selecting part of the text and then tabbing off. Therefore, I think this is not a bug. The only thing which makes me slightly doubt myself is that this behaviour is platform-specific, and not reproducible on Linux, but this could just be down to Windows design guidelines.

IMO, this issue should be closed as "not a bug". If you think this is an issue that should be taken further, please raise it with the Tk team: https://core.tcl-lang.org/tk/reportlist
msg406420 - (view) Author: Chris Eykamp (watusimoto2) Date: 2021-11-16 17:32
The behavior I described is definitely a bug, though it may be (and I suspect is) Windows specific.  You may also be right that the problem is upstream, but please don't declare this "not a bug" until you've tested it on Windows.
msg406435 - (view) Author: E. Paine (epaine) * Date: 2021-11-16 21:35
> please don't declare this "not a bug" until you've tested it on Windows

Sorry, I didn't explain my reasoning for that resolution. I did test it on Windows, but my trail of though went something like: "unexpected behaviour doesn't necessarily mean it's a bug". You are right, though, and a resolution of "third party" would be more suitable.
msg406442 - (view) Author: Chris Eykamp (watusimoto) * Date: 2021-11-16 22:55
Thanks for the clarification.  I don't want to belabor the point, but if you observe what happens as you hit tab and cycle through the widgets, the way the color changes cannot be intended behavior, and makes no sense from any rational UI perspective.  

I do accept that it may not be a Python bug (though I don't really know); I do not understand the relationship between Python and Tcl in terms of who is responsible for what.  But regardless, I filed a bug report at the URL you provided.  I don't know if they accept documentation of problems written in Python, and I cannot write the code in Tcl, but we'll find out in a day or two (I hope).

Thanks again!

On Tue, Nov 16, 2021, at 13:35, E. Paine wrote:
> E. Paine <xepaine13@gmail.com> added the comment:
>
>> please don't declare this "not a bug" until you've tested it on Windows
>
> Sorry, I didn't explain my reasoning for that resolution. I did test it 
> on Windows, but my trail of though went something like: "unexpected 
> behaviour doesn't necessarily mean it's a bug". You are right, though, 
> and a resolution of "third party" would be more suitable.
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue45796>
> _______________________________________
msg406496 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2021-11-17 21:40
For the record, the Tk issue opened for this is at:
https://core.tcl-lang.org/tk/tktview?name=300bad1beb
msg407130 - (view) Author: Chris Eykamp (watusimoto) * Date: 2021-11-27 03:22
If we decide that this is a tkinter bug (and that the Python part is working properly), does that mean that we close this ticket and rely on the upstream provider to fix the problem?  I don't know how jurisdiction works with core libraries shipped with Python.
msg407131 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2021-11-27 03:38
This issue was already closed under the presumption that what you described is Tk behavior. tkinter is the module in the Python standard library that provides the “glue” to the third-party TCL and Tk libraries; it is pretty much a thin wrapper that provides little functionality on its own. If the Tk folks ultimately reject your Tk issue and believe it is really a problem in Python’s tkinter module, feel free to reopen this issue. (Note, that in general, the Tcl and Tk libraries themselves are not part of Python, however we do provide pre-compiled versions of the libraries with the the Windows and macOS Python binary installers on python.org.)
History
Date User Action Args
2022-04-11 14:59:52adminsetgithub: 89954
2021-11-27 03:38:40ned.deilysetmessages: + msg407131
2021-11-27 03:22:17watusimotosetmessages: + msg407130
2021-11-17 21:40:45ned.deilysetnosy: + ned.deily
messages: + msg406496
2021-11-17 21:38:58ned.deilysetstatus: open -> closed
resolution: third party
stage: resolved
2021-11-16 22:55:57watusimotosetmessages: + msg406442
2021-11-16 21:35:43epainesetmessages: + msg406435
2021-11-16 17:32:50watusimoto2setnosy: + watusimoto2
messages: + msg406420
2021-11-14 15:13:14epainesetnosy: + serhiy.storchaka, epaine
messages: + msg406323
2021-11-12 21:54:43watusimotosetmessages: + msg406243
2021-11-12 21:51:34watusimotocreate