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

Sibylle Koczian nulla.epistola at web.de
Tue Apr 30 09:43:54 EDT 2019


Am 29.04.2019 um 22:51 schrieb Michael Lange:
> 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".
> 

That would be very nice. But no, I just forgot to mention it: I tried 
with hex color specs and I tried with the most simple color names: just 
"green" (and "white" for the foreground color of bavarian towns). 
Nothing. BTW I used Python 3.7.3 with Windows 10 and with ArchLinux, 
LXQt as desktop, everything freshly updated.

Thank you,
Sibylle


More information about the Tkinter-discuss mailing list