Python Forum
A problem with a TButton's foreground 'active' color. - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: A problem with a TButton's foreground 'active' color. (/thread-29557.html)



A problem with a TButton's foreground 'active' color. - Mik3e - Sep-10-2020

My program runs a timing loop and has 13 widgets in the window, four are buttons. The style map sets the button's 'active' foreground color to red, and it works as expected on three of the buttons. The situation is with the 'stop'/'reset' button. The 'stop' button interrupts the decrement loop and becomes a 'reset' button, which cleans the slate and gets ready for the next timing. The 'reset' button's state is initially set 'disabled' so it won't be clicked early, before the decrement loop completes it's cycle, which causes errors. When the decrement loop is stopped, and just before it returns 0, the 'reset' button's state is set to 'normal'. And here is the situation, the mouse cursor is still on the button, but the now-normal button doesn't know it should be 'active', so the text is not red. I can move the mouse off the button and back on, and get red text, as expected.

I have set the button state to 'active' and the text is red, but the problem is reversed. It stays red until I move the mouse back on and off the button.

So here's the question, is there a way for the program to interrogate the button to determine if there's a mouse cursor on it, and change to the appropriate state?

Mike

Linux Mint, python3.8, ttk widgets