in reply to Perl::Tk--Center line in Text Widget

If you have, say, 100 lines in the text file and only 10 lines are visible at any time in the text widget, and you want line 50 to be shown in the center of the widget... $text->see(50) will scroll it so that line 50 is at the bottom of the text box, but if you did instead $text->see(50 + 5) then it would show line 55 at the bottom of the text box, and line 45 at the top - 50 being approximately right in the center.

Then to guarantee it will be in the center even if the text widget needed to scroll up to see it, you could first call $text->see(45) and then $text->see(55).

  • Comment on Re: Perl::Tk--Center line in Text Widget

Replies are listed 'Best First'.
Re^2: Perl::Tk--Center line in Text Widget
by vlsimpson (Beadle) on Dec 19, 2009 at 07:29 UTC

    Excellent, that looks like it'll do it. I'll give it a whirl in the morning (well, my later morning).

    Thanks.