This is quite an old question, but considering I stumbled upon it today looking for an answer, others with the same issue might appreciate this being updated.
The way I solved this was by setting the lmargincolor
option in the tag configuration to the background color of the Text
widget. This will paint the margin added by lmargin1
/lmargin2
in that color (see the official manual).
In my case, this looked like this:
text_widget.tag_configure(
tagName="warning",
background="#ff9800",
lmargin1=margin1
lmargin2=margin2,
lmargincolor=text_widget.cget("background")
)
Alternatively, you could of course use a static color like #FFF
.
This worked like a charm for me, resulting in this look (with the amber-background text being the tag in question).