in reply to Tk:Text resize dillema

Sounds difficult. For trapping resize events (and other window manager-related events like exposing) you can bind the <Configure> event. You have to be careful when setting the size of the text widget: if geometry propagation is turned on (which by default is), then any change to the child windows will change the size of the toplevel window, which in turn could cause a resize (if your geometry calculation were not exact) and this would again cause a <Configure> event and so on.

The other difficult part is determining the total line number or the xy position of the last character in the text widget. It's easy if the text is completely visible. In this case you can use a method like dlineinfo or bbox. But if the end of text is invisible because it's larger than the widget, then I don't know of any way to get information about the end.

Replies are listed 'Best First'.
Re^2: Tk:Text resize dillema
by gri6507 (Deacon) on Dec 19, 2006 at 22:22 UTC
    Thanks for the reply. I've played around with the dlineinfo() method, but it returns information in Pixels. How do I convert from pixels to actual width of characters and height of lines?
      You can use the ascent/descent information from the fontMetrics call. Of course, this does not help if you have embedded images or widgets in your text widget.