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

Hi all, I think the Mlistbox widget is powerful and flexible to config. I try to make the last row expand to fill the entil frame but it only fill the y direction. Does anyone know any trick to make the last column extended?.

use strict; use warnings; use Tk; use Tk::MListbox; my $mw = MainWindow->new(); $mw->geometry("900x500"); my $frame = $mw->Frame()->pack(-side=>'top', -fill=>'both', -expand=>1 +); my $mlb = $frame->MListbox()->pack(-side=>'top', -fill=>'both', -expan +d=>1); $mlb->columnInsert(0, -text=>'count'); $mlb->columnInsert(1, -text=>'date'); $mlb->columnInsert(2, -text=>'size'); Tk::MainLoop;
thanks in advance.

Replies are listed 'Best First'.
Re: MListbox - please help
by Khen1950fx (Canon) on Feb 13, 2010 at 04:09 UTC
    To extend the last column:
    #!/usr/bin/perl use strict; use warnings; use Tk; use Tk::MListbox; my $mw = MainWindow->new(); $mw->geometry("900x500"); my $frame = $mw->Frame()->pack( -side=>'top', -fill=>'both', -expand=> +1); my $mlb = $frame->MListbox()->pack(-side=>'top', -fill=>'both', -expan +d=>1); $mlb->columnInsert(0, -text=>'count'); $mlb->columnInsert(1, -text=>'date'); $mlb->columnInsert(2, -text=>'size')->pack(-expand => 1); MainLoop;
      On my Perl 5.10, and latest Tk, you need to click on the 'size' header to actually get it to fill in the $mw after it opens. A hack to get around it, is to set a very high width for that column, and let it fill in from the right side.

      There may be a better way. :-)

      $mlb->columnInsert(2, -text=>'size', -width=>1000 )->pack(-expand => + 1);

      I'm not really a human, but I play one on earth.
      Old Perl Programmer Haiku
        Thanks for the tip. Extends the size header perfectly.