#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::HList; # googled example by Rob Seegel my $mw = new MainWindow; my $hl = $mw->Scrolled( 'HList', -scrollbars => 'os', -background => 'white', -columns => 4, -header => 1, -width => 40, -height => 5 )->pack; my $bgcolor = "bisque"; foreach my $column ( 0 .. 3 ) { ## Create the Clickable Header my $b = $hl->Button( -background => $bgcolor, -anchor => 'center', -text => "Header$column", -command => sub { print "You pressed Header $column\n"; } ); $hl->headerCreate( $column, -itemtype => 'window', -borderwidth => -2, -headerbackground => $bgcolor, -widget => $b ); } MainLoop; #### #!/usr/bin/perl -w use strict; use Tk; #this leaks my $mw = Tk::MainWindow->new( -title => 'Listbox Leak' ); my $lb = $mw->Listbox()->pack(); my $b = $mw->Button( -text => 'Leak', -command => \&leak )->pack(); MainLoop; sub leak { $lb->delete( 0, 'end' ); $lb->insert( 'end', 1 .. 10000 ); } #### ##################################### #!/usr/bin/perl use warnings; use strict; use Tk; #no leaks, but watch out for @array being empty...crash #make sure @array has at least a ''; my $mw = Tk::MainWindow->new(-title => 'Listbox Leak'); my @array = (1..10000); my $lb = $mw->Listbox( -listvariable=> \@array, )->pack(); my $b = $mw->Button(-text => 'Leak', -command => \&leak )->pack(); MainLoop; sub leak { @array = map{"$_.a"}(1..10000); $lb->update; }