[wxPython-users] TextCtrl wrap length?

Robin Dunn robin at alldunn.com
Fri May 11 14:32:27 PDT 2007


Bob Robison wrote:
> I have a multi-line TextCtrl that is in a re-sizable window.  As the
> window is re-sized, the text is appropriately re-wrapped.  Is there
> anyway to determine how many characters wide the widget is at any
> point?

That depends on what text is on the line and the font being used. 
Glyphs in proportional fonts can have (and usually do have) uneven 
widths so a line with a lot of i's or .'s in it is going to hold a lot 
more characters than one with a lot of W's.  If you use a monospaced 
font then you can get a close estimation by dividing the width of the 
control by the character width for the font, but there will still be 
some extra space used by the control for internal margins, maybe the 
scrollbar, etc.

-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wxpython-users mailing list