Determining word wraps in Tkinter text widget

Martin Franklin martin.franklin at westgeo.com
Tue Nov 27 14:08:33 CET 2001


David Wangerin wrote:

> When the text widget is configured for wrapping text on words, is
> there an easy and/or elegant method for determining if a specific line
> of text has been wrapped?
> 
> I've been developing an app with a text box and some widgets that
> float next to each text line, but when a line is too long and gets
> wrapped, my floating widgets get out of place.  By using
> Text.dlineinfo(INSERT) I can get the width in pixels, but this is not
> too useful unless I do some conversions based on the font size (which
> I'd rather avoid doing).  In addition, when my window is resized, the
> Text.cget('width') does not update to reflect the new size.
> 
> I could set the wrap to none and add a horizontal scrollbar, but this
> really makes the application ugly and is a last resort.
> 
> Anyone have any ideas?
> 
> Thanks,
> 
> David Wangerin...
> 

David,

Not really an answer but you could try the Pmw.ScrolledTextbox mega-widget
the scroll bars are dynamic (only seen if needed).

What do you mean by floating widgets (do you mean window's inside the 
textbox) or next to the textbox in an adjacent frame?

Regards,
Martin.















More information about the Python-list mailing list