Updated 2013-02-01 04:13:42 by RLE

schlenk, 19. July 2005: Answering a question on self-tcl.de [1] i came up with this little demo. It shows how to dynamically resize a label with some text, when the window is resized:
 package require Tk
 package require math::interpolate

 proc createInterpolationTable {win font text} {
   set max [winfo vrootwidth $win]
   set oldsize [font configure $font -size]
   set xval [list]
   set yval [list]
   set x 0
   set size 2
   while {$x < $max} {
      font configure $font -size $size
      set x [font measure $font $text]
      lappend xval $x
      lappend yval $size
      incr size 4
   }
  font configure $font -size $oldsize
  return [list $xval $yval]
 }

 proc adjustFont {font width ipt} {
   set newSize [lindex [math::interpolate::neville [lindex $ipt 0] [lindex $ipt 1] $width] 0]
   font configure $font -size [expr {int($newSize)}]
 }

 proc configureBinding {font ipt win width heigth} {
    adjustFont $font $width $ipt
 }

 font create title -family Verdana -size 10
 toplevel .test
 set txt "Some Titel"
 set ipt [createInterpolationTable .test title $txt]
 label .test.l -text $txt -font title
 pack  .test.l -expand 1 -fill both
 bind  .test.l <Configure> [list configureBinding title $ipt %W %w %h] 

MHo - 2008-02-27: just tested on windows. After starting the program, I had no chance to klick anything: the window constantly flickers. Had to press Alt+F4 to cancel. Looks like the Configure-event is constantly fired...

See also font