I am building an interface that has a Treeview to display a list of items.
I would like for some items to be displayed with italic font.
I understood that a Treeview can apply a tag to its items, tags have bound properties - including a font that will be applied to the items containing that tag.
First try
I have tried creating a tag with a new font, passing only the italic property to such font, but the results were awful:
treeview.tag_configure(
'content_modified', font=font.Font(slant='italic'))
I realized that I was creating a whole new font, not only an italic effect font, and the base font not necessarily is the same as the one being used by the Treeview.
Second try
After reading the documentation about default fonts, I noticed that the Treeview probably (?) uses a font named TkTextFont for its items, so I decided to make a copy of it and apply an italic modification to the copy, and then use the new font as a property to the tag:
italic_font = font.Font(font=font.nametofont('TkTextFont'))
italic_font.config(slant='italic', weight='bold')
treeview.tag_configure(
'content_modified', font=italic_font)
I got the desired result visually, but the code is bothering me.
The problem
- I would like to be able to query the
Treeviewfor the font that it is using, and I could not find a way to do that. I would rather copy the queried font instead of a global named font expecting it to be the one that theTreeviewis using.

