Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am loading columns into an Hlist but can't find what the maximum number of columns allowed is. I am having what I call a "buffer overflow" problem when I have over 300 columns. Will I have better luck using a listbox over an hlist?

Replies are listed 'Best First'.
Re: Size limit of Hlist v. Listbox
by Fletch (Bishop) on Mar 10, 2008 at 21:16 UTC

    You might have better luck asking a more cogent question wherein you give sample code and more context such as what exactly you're trying to do. (Is this in a web page? Is this with Tk?) See How (Not) To Ask A Question.

    (Likewise that's not a "buffer overflow"; that term's already got a completely different meaning and misusing it is only going to confuse things.)

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Re: Size limit of Hlist v. Listbox
by zentara (Cardinal) on Mar 11, 2008 at 12:34 UTC
    Try this, it works fine here on linux.
    #!/usr/bin/perl use warnings; use strict; use Tk; use Tk::HList; my $mw = new MainWindow; my $hl = $mw->Scrolled( 'HList', -scrollbars => 'osoe', -background => 'white', -columns => 400, -header => 1, -width => 10, -height => 5, -command => sub{ print "AAA\n"}, )->pack(-fill=>'both',-expand=> 1); my $bgcolor = "bisque"; foreach my $column ( 0 .. 399 ) { ## 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 ); } foreach my $num(1..10) { my $e = $hl->addchild(""); #will add at end foreach my $col(0..399){ $hl->itemCreate ($e, $col, -itemtype => 'text', -text => "$num-$col", ); } } MainLoop;

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum