This is a test code:

##############################################################################
##############################################################################
use strict;
use Time::HiRes qw(time usleep);
use Tk;
require Tk::ROText;

my $mw = MainWindow->new( );
$mw->minsize(450,250);
$mw->maxsize(450,250);

my %frames;
$frames{'name'}        = $mw->Frame( -borderwidth => 2, )->pack( -side =>
'top', -expand => 0, -fill => 'x', );
$frames{'input'}    = $mw->Frame( -borderwidth => 2, )->pack( -side =>
'top', -expand => 0, -fill => 'x');

$frames{'name-l'}    = $frames{'name'}->Label       (       -font =>
['Courier',10,'bold'  ], -relief => 'groove', -anchor => 'nw', -width => 16,
-text => 'Name ',                     )->pack( -side => 'left',  -expand =>
0, -fill => 'y', );
$frames{'name-r'}    = $frames{'name'}->Scrolled    ('ROText', -font =>
['Courier',10,'normal'], -relief => 'groove',                  -height =>10,
-scrollbars => 'e', -cursor => 'top_left_arrow'  )->pack( -side => 'right',
-expand => 1, -fill => 'x', );

$frames{'buttonL'}    = $frames{'input'}->Button    ( -font =>
['Terminal',10,'bold'],-relief => 'raised',    -width => 20, -borderwidth =>
1, -text => 'GOTO  1', -command => [\&ScrollTOP]  )->pack( -side => 'left',
-expand => 0, -fill => 'x', -padx=>1);
$frames{'buttonC'}    = $frames{'input'}->Button    ( -font =>
['Terminal',10,'bold'],-relief => 'raised',    -width => 20, -borderwidth =>
1, -text => 'GOTO 50', -command => [\&ScrollMID] )->pack( -side => 'left',
-expand => 0, -fill => 'x', -padx=>1);
$frames{'buttonR'}    = $frames{'input'}->Button    ( -font =>
['Terminal',10,'bold'],-relief => 'raised',    -width => 20, -borderwidth =>
1, -text => 'GOTO 90', -command => [\&ScrollBOTTOM] )->pack( -side =>
'left', -expand => 0, -fill => 'x', -padx=>1);

#    I dont know what TK codes to use to scroll the Scrolled panel to the
desired location
sub ScrollTOP {
}
sub ScrollMID {
}
sub ScrollBOTTOM {
}

for (my $i=1; $i<=100; $i++) {
    $frames{'name-r'}->insert('end', "Line $i\n", "A$i");
}

while (1) {
    $mw->update();
    usleep 50000;
}
##############################################################################
##############################################################################

3 Buttons:
GOTO 1
GOTO 50
GOTO 90

if I press GOTO 1, it will scroll to Line 1
If I press GOTO 50, it will scroll to Line 50
if I press GOTO 90, it will scroll to Line 90

I appreciate if you could help me on this

Thanks!
Dan




On Sun, Dec 7, 2008 at 6:45 PM, Daniel Burgaud <[EMAIL PROTECTED]> wrote:

> 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.
>
>
>
>
>
> On Sun, Dec 7, 2008 at 1:07 PM, Jack <[EMAIL PROTECTED]> wrote:
>
>>
>> _______________________________
>>
>> From: [EMAIL PROTECTED]
>> [mailto:[EMAIL PROTECTED] On Behalf Of
>> Daniel Burgaud
>> Sent: December-06-08 7:16 PM
>> To: Perl-Win32-Users
>> Subject: Q on TK Scrolled: how do scroll?
>>
>>
>> >I have a TK scrollbar defined as follows:
>>
>> >$frames{'name-r'}  = $frames{'name'}->Scrolled  ('ROText', -height => 8,
>> -scrollbars => 'e',  )->pack( -side => 'right', -expand => 1, -fill =>
>> 'x',
>> );
>>
>> >My problem is:
>>
>> >How do I command it to show the middle, the bottom, the top of the
>> scrollbar?
>>
>> ###############################
>> I can likely help - but I really don't understand your question.
>> What do you mean by "show the middle, bottom and top"?
>>
>> Perhaps you can post a small sample program that demonstrates your
>> problem.
>>
>> Jack
>>
>>
>> _______________________________________________
>> Perl-Win32-Users mailing list
>> Perl-Win32-Users@listserv.ActiveState.com
>> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>>
>
>
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to