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();
In reply to Seeking way to dynamically change listbox height by CrashBlossom
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |