Determining word wraps in Tkinter text widget

David Wangerin dwangeri at uci.edu
Tue Nov 27 05:18:35 EST 2001


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...



More information about the Python-list mailing list