[Tkinter-discuss] horizontal line in Text

Alan Gauld alan.gauld at yahoo.co.uk
Fri Jan 24 07:19:21 EST 2020


On 24/01/2020 09:15, Michael Lange wrote:

>>> is it possible to draw a horizontal line in the Text() widget,
>>> something like the <hr> in html, extending all over the widget.
>>
>> Would a line of spaces with the underline turned on in the font work?
>> If you use a monospace font the length should be fairly predictable.
>>
>> Just a thought.
> 
> I think the problem with all text based solutions is that these "lines"
> will not resize along with the text widget and worse, might line-break
> when the widget size is being reduced.

Yeah, after I posted I had a bit of a think and tried a few things out.
I came to the conclusion you really need a widget class that would
handle all those kinds of things. The humble <hr> tag has quite a
lot of functionality when you start digging deeper. (size by absolute
or percent, styles, thickness, etc)

But if its just a divider in a text field, underline of overstrike
might work as a casual fix. You could handle resize events if
needed, but not much more.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos



More information about the Tkinter-discuss mailing list