in reply to Re: Re: Perl/Tk: Need Assistance with use of pack()
in thread Perl/Tk: Need Assistance with use of pack()

I suggest a healty reading of Tk::pack (fyi, it is not the only geometry manager)
use Tk; use strict; use warnings; my $mw = MainWindow->new( -bg => 'beige', ); my $l = $mw->Frame( -width => 111, -height => 333, -relief => "raised", -borderwidth => 2, -bg => '#EEE000', )->pack( -fill => 'x', -side => 'left', -anchor => 'n', ); my $r = $mw->Frame( -width => 111, -height => 333, -relief => "raised", -borderwidth => 2, -bg => '#F0F000', )->pack( -fill => 'both', -side => 'left', -anchor => 'n', ); my $r2 = $mw->Frame( -width => 111, -height => 333, -relief => "raised", -borderwidth => 2, -bg => '#F0F000', )->pack( -fill => 'both', -side => 'left', -anchor => 'n', ); for( qw[ Name: Version: Description: Date: ] ){ $l->Label( -text => $_, # -justify => 'right', -anchor => 'e', )->pack( #-anchor => 'e', # if you don't fill -fill => 'x', ); $r->Label( -text => $_, # -justify => 'right', -anchor => 'e', )->pack( -anchor => 'e', # if you don't fill #-fill => 'x', ); $r2->Label( -text => $_, -justify => 'right', # -anchor => 'e', )->pack( #-anchor => 'e', # if you don't fill #-fill => 'x', ); } #$top->Label(-text => "Enter the scroll frame")->pack; MainLoop;

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
Re: Re: Re: Re: Perl/Tk: Need Assistance with use of pack()
by ozboomer (Friar) on Apr 25, 2004 at 13:22 UTC
    I've read the docs on pack but couldn't get my head around the 'parcels' and 'cavities' that were referred to. I couldn't get grid to work at all (my program would hang) and I haven't yet tried place. As I've said, I'm new to Tk and I'm just trying to understand how the module works.

    Many thanks for your post.

    John

      You can't mix pack() and grid() in the same frame or toplevel (this would cause your program hanging). Either use grid() all over the place or create a frame where you just use grid().