[Tkinter-discuss] ttk.Treeview: coloring rows using tags doesn't work with Python 3.7.3

Michael Lange klappnase at web.de
Mon Apr 29 16:51:13 EDT 2019


Hi,

On Mon, 29 Apr 2019 13:16:50 +0200
Sibylle Koczian <nulla.epistola at web.de> wrote:

> Hello,
>
> the following script shows a Treeview with names and country codes of
> some towns in Germany. Towns with country code "HE" or "BY" should be
> shown with coloured background, in the case of "BY" additionally with
> white text.
>
> This works using Python 3.5 or 3.6. I seem to remember that it worked
> with earlier versions of Python 3.7, but that's not certain. Using
> Python 3.7.3 all the entries have white background and black text.
> Opening an entry with Enter or double click shows the name of the town
> in the Entry field, together with the country name, if the row has the
> tag for HE or BY. So the entries have the tags they should, but the
> color doesn't change.
>
> Changing the font of an entry using tags does work.
>
> All of these Python versions come with tcl/tk version 8.6, but I don't
> know the patch numbers, they probably changed. The official
> documentation for tkinter and for tcl/tk seems to show that the script
> is correct. I can see no hint of recent changes in the use of tags,
> tag_configure and the options usable with tags.

just a shot into the dark:

maybe the problem is not at all how the treeview handles tags, but how Tk
handles named colors? Did you try to use hex color specs like '#d9d9d9'
instead of 'darkgray' or 'lightgreen'? According to
https://www.tcl-lang.org/man/tcl8.6/TkCmd/colors.htm
there should be "dark gray" and "LightGreen", but maybe your version of
Tk somehow fails to treat the color names case-insensitive resp.
"space-insensitive".

Best regards

Michael


.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

Space: the final frontier.  These are the voyages of the starship
Enterprise. Its five-year mission: to explore strange new worlds; to seek
out new life and new civilizations; to boldly go where no man has gone
before.
		-- Captain James T. Kirk


More information about the Tkinter-discuss mailing list