From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Daniel Burgaud Sent: December-07-08 3:46 AM To: Jack Cc: Perl-Win32-Users Subject: Re: Q on TK Scrolled: how do scroll?
Hi Jack, The scrollbed field is defined as: $frames{'name-r'} = $frames{'name'}->Scrolled ('ROText', -height => 8, -scrollbars => 'e', )->pack( -side => 'right', -expand => 1, -fill => 'x', It can scroll up/down and contains text. I want to do a "search" and therefore the script should display the part where the search string is located within this scrolled field. I dont know how to write that part of the script because I dont know how to. I hope you understood my question. So basically, I want the script to automatically scroll to the location where this text is located. I have tried playing with: $frames{'name-r'}->set(0.5, 0.6) $frames{'name-r'}->see(0.5) with no success - I totally dont have a clue what these two did too. Hoping for help. Dan. ######################################### Ok then. Now I get it. You are on the right track. The 'see' method is the one you want to use. If you are doing a 'search', then that method will return the first index that matches your search pattern. Just pass that to the 'see' method to autoscroll to that location. Here is a working example: ############################################ use Tk; use strict; my $pattern='00'; my $lastindex='1.0'; my $mw=tkinit; my $t=$mw->Scrolled('Text', -scrollbars=>'ose') ->pack(-expand=>1, -fill=>'both'); for (1..1000) { $t->insert('end',"$_\n"); } my $id = $t->repeat(1000,[\&searchit,$pattern]); MainLoop; sub searchit { my ($p) = @_; warn $lastindex; my $index = $t->search($p,"$lastindex". '+ 1 lines','end'); unless ($index) { $id->cancel; return; } $t->see($index) if $index; $lastindex=$index; } ############################################## _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs