SourceForge has been redesigned. Learn more.

#2759 'text see' doesn't work when the text is not yet

obsolete: 8.5.5
Eric Brunel

An initial 'text see' command issued just after populating the text often doesn't work. In specific cases of complex layout, and/or when the text contains a lot of lines, doing 'update idletasks' or 'update' before the 'text see' doesn't solve the problem, and neither does performing the see in an 'after idle' or via a custom event sent via 'event generate'.

The wrong behavior can be seen with the attached example script: the initial call to center_text does not center the line in the text on display. Successive calls via the 'Center' button work.

A workaround seems to be to add the following lines at the beginning of proc center_text:
.texts.txt count -update -ypixels 1.0 end
.texts.lines count -update -ypixels 1.0 end
and to replace the line center_text with:
tkwait visibility .texts
after idle after 5 center_text
(thanks to Peter Spjuth for this)

This workaround is quite complicated and basically impossible to find without help. It would be better if an initial 'text see' command worked out of the box, without any need for such a trick.


  • Eric Brunel

    Eric Brunel - 2010-02-11
  • Martyn Smith

    Martyn Smith - 2013-05-15

    I am having the same problem with the 'yview moveto' command, if I trace the value, I set 0. 9 and then ask for 'yview' it returns "0.0 1.0" with about 1500 lines in the widget

    I too found the 'count -update' trick but with several text widgets and several thousand lines of text it hangs the display for several seconds (on an i7 with 8GB RAM), plus the yview seems to shift down slightly every reload.

    I even tried 'yview scroll xxx units' which did not work either.

  • Martyn Smith

    Martyn Smith - 2013-05-15

    I forgot to mention that this is with TCL8.6.0 so the problem is still present

  • Martyn Smith

    Martyn Smith - 2013-05-15

    I just updated my code to use the obsoleted -pickplace option and that works correctly.

    However when I update the attached code (replace see by yview -pickplace) it does nothing and clicking on the button as soon as the display appears produces a sort of scrolling animation which stops after a moment but not on the correct line.

    Its as if the text widget is updating something in the background