in reply to Changing Buttonsize in MListbox

Buttons and Labels in Tk are text-line oriented. You can't really set the height or width in pixels, when you set the width, it's the character width of the text (at the font it's using). The height can only be changed by putting newlines in it's text. Here are 2 examples:
#!/usr/bin/perl use Tk; use Tk::MListbox; use strict; use warnings; my $mw = new MainWindow(); my $frame = $mw->Frame(-bd => 2, -relief => 'raised')->pack(-expand => + 1, -fill => 'both'); my $scrolledMListbox = $frame->Scrolled( qw/MListbox -selectmode browse -scrollbars oe/ )->pack(-expand => 1, -fill => 'both'); my @list = ( "a", "b" ); $scrolledMListbox->columnInsert('end', -text => "\nPath\n"); $scrolledMListbox->columnInsert('end', -text => "\nModified\n"); $scrolledMListbox->columnInsert('end', -text => "\nDir\n"); $scrolledMListbox->columnInsert('end', -text => "\nFile\n"); $scrolledMListbox->insert('end', [ "a", "b", "s", "l"] ); $scrolledMListbox->insert('end', [ "c", "d", "f", "e"] ); MainLoop;
or you can try to set a font size.
#!/usr/bin/perl use Tk; use Tk::MListbox; use strict; use warnings; my $mw = new MainWindow(); $mw->fontCreate('big', -family=>'arial', -weight=>'bold', -size=> 18 ); $mw->fontCreate('medium', -family=>'arial', -weight=>'bold', -size=> 14 ); my $frame = $mw->Frame(-bd => 2, -relief => 'raised')->pack(-expand => + 1, -fill => 'both'); my $scrolledMListbox = $frame->Scrolled( qw/MListbox -selectmode browse -scrollbars oe -font medium / )->pack(-expand => 1, -fill => 'both'); my @list = ( "a", "b" ); $scrolledMListbox->columnInsert('end', -text => "Path",-font => 'big' +); $scrolledMListbox->columnInsert('end', -text => "Modified",-font => 'b +ig'); $scrolledMListbox->columnInsert('end', -text => "Dir",-font => 'big') +; $scrolledMListbox->columnInsert('end', -text => "File",-font => 'big' +); $scrolledMListbox->insert('end', [ "a", "b", "s", "l"] ); $scrolledMListbox->insert('end', [ "c", "d", "f", "e"] ); MainLoop;

I'm not really a human, but I play one on earth. flash japh

Replies are listed 'Best First'.
Re^2: Changing Buttonsize in MListbox
by Ace128 (Hermit) on Sep 16, 2005 at 02:04 UTC
    Well, if you try that I mentioned I do make it thinner! But it's not working for them all buttons, and I dunno why! (well, atleast it's not working directly, when creating the MListbox!, which I want).

    Tried inserting my addon to the MListbox.pm? That "18" in height in pixels makes the button thin, when I click or drag in there...

      After you have created your MListbox, try adding the following code:

      foreach my $column ($mlistbox->columnGet(0, 'end')) { $column->Subwidget("heading")->configure(-pady => 0); }

      Sometimes, by tweaking the pady option you can get the height you want. Does this give the desired result?

      Rob