CrashBlossom has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks,
Does anyone know if it is possible to change the height of a listbox after it has been created?
I tried to use the configure method to change the -height option, but that seems to have no effect. Curiously, subsequent calls to cget return the new height value, even though the actual height has not changed. My test program is below.
Can anyone help me understand what is going on? Thanks ...
use strict; use warnings; use Tk qw(MainLoop); my $mw = MainWindow->new(-title => " Listbox Height-Change Test"); my $myFont = "{Lucida Fax} 12 bold"; my ($lb, $lbw); $mw->Button(-text => 'Print Height', -font => $myFont, -command => sub { print "HEIGHT: ", $lb->cget(-height), "\n"; } +, )->pack(); $mw->Button(-text => 'Change Height', -font => $myFont, -command => sub { $lb->configure(-height=>5); }, )->pack(); my @items = ("thing1", "THing2", "THING3"); $lb = $mw->Scrolled('Listbox', -font => $myFont, -background => 'darkblue', -foreground => 'white', -scrollbars => 'osoe', -height => 15, -width => 28, -borderwidth => 1, -relief => 'solid', )->pack(); # $lbw = $lb->Subwidget('listbox'); $lb->delete(0,'end'); my $num = 0; $lb->insert('end', sprintf("%3d. $_\n", ++$num)) for (@items); MainLoop();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Seeking way to dynamically change listbox height
by choroba (Cardinal) on Sep 04, 2021 at 22:18 UTC | |
|
Re: Seeking way to dynamically change listbox height
by CrashBlossom (Beadle) on Sep 04, 2021 at 23:24 UTC | |
|
Re: Seeking way to dynamically change listbox height
by CrashBlossom (Beadle) on Sep 05, 2021 at 01:04 UTC | |
|
Re: Seeking way to dynamically change listbox height
by Anonymous Monk on Sep 05, 2021 at 00:47 UTC |