Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl/Tk Scrollbar

Status
Not open for further replies.

mgeurts

Programmer
Apr 30, 2002
13
US
I have a listbox with a scrollbar, but the scrollbar has some problems. First, It's really small, and second, when I click on the scrollbar arrow, the list will scroll, but only once. What is going on? Here is some script:

use Tk;
$homelist = $homeframe->Listbox(
-height=>20,
-background=>white,
-width=>120);
$homelist->pack(-side=>left);
$homelist->bind(&quot;<Double-1>&quot;,[\&open]);
$homelist->yview(scroll,1,units);

$scrollbar = $homeframe->Scrollbar(-command=>[yview=>$homelist]);
$scrollbar->pack(-side=>right);

Thanks, Mark
 
Mark,

I would have used the Scrolled constructor.

$whatever = $parent->Scrolled(
Whatever ?,
-scrollbars => where? ?,
...?
);

Mike
______________________________________________________________________
&quot;Experience is the comb that Nature gives us after we are bald.&quot;

Is that a haiku?
I never could get the hang
of writing those things.
 
How would I then add elements to the listbox?

Mark
 
Like this,

Code:
$list_box = $main_text_container->Scrolled(&quot;Listbox&quot;,
    -selectmode=>&quot;single&quot;,
            -width=>'63',
            -height=>'3',
            -scrollbars=>&quot;e&quot;,
            -background=>&quot;white&quot;,
            -cursor=>'arrow');
@values = split(/,/,$tmp);
$list_box ->insert('end',@values);
'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
I tried your suggestion, but all I get is an empty window. Here is the code I entered. Maybe you can help find what is causing the empty window:

$mainwindow = MainWindow->new();
$homeframe = $mainwindow->Frame();
$homeframe->pack();
$homelist = $homeframe->Scrolled(listbox,
-selectmode=>single,
-height=>20,
-background=>white,
-width=>120,
-scrollbars=>e,
-cursor=>arrow
);
$homelist->pack(-side=>left);
$homelist->bind(&quot;<Double-1>&quot;,[\&open]);
$homelist->yview(scroll,1,units);

open (HOME,&quot;homelist.txt&quot;);
@topics = <HOME>;
close HOME;

foreach $topicline (@topics) {
@homefields = split (/;;/,$topicline);
$hashtopics{$homefields[0]} = $homefields[2];
}

foreach $indtopic (sort keys %hashtopics) {
$homelist->insert(end,$indtopic);
}



$numtopics = $homelist->size;
 
Don't even answer that question- I am stupid! It should be &quot;Listbox&quot; instead of &quot;listbox&quot; Well, that's what I get for not paying attention to my typing. Thanks Mike and GoBoating! One more problem solved, another from an endless list upcoming....

Mark
(I'm not usually this bitter about life)
 
hey - that endless list is job security. [pc2]

'glad i could help, as I'm sure mike is. 'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top