Someone please enlighten me. I can't for the world figure out what is
wrong here.


- I create a main window.

- In this window I create a frame.

- In this frame I create four buttons.

- The buttons need to be packed like this:

         TOP

   LEFT      RIGHT

   BOTTOM1 BOTTOM2


-Instead they are packed like this:

         TOP

      LEFT RIGHT

         BOTTOM2

      BOTTOM1


- So I increase the frame size with -width => '500' and -height =>
'500'.

- Result: nothing happens. The frame doesn't become 500x500.


Unfortunately Nancy Walsh doesn't give many code examples in her book.
I've been at pTk for 5 months now, but still can't get things to pack
right. Her explanation on allocation rectangles is clear, but the
examples are too simple: how about writing a more complicated app with
many widgets in odd positions from eachother?


Anyway, here's the code I've tried the above with:


#!/usr/bin/perl -w

use strict;

use English;

use Tk;


my $mw = MainWindow->new;


my $top_frame = $mw->Frame(-width => '500', -height => '500',
-borderwidth => '4', -relief => 'groove', -background => 'blue');

$top_frame->pack();


my $bttn1 = $top_frame->Button(-text => 'TOP')->pack(-side => 'top');

my $bttn2 = $top_frame->Button(-text => 'BOTTOM1')->pack(-side =>
'bottom', -anchor => 'w');

my $bttn3 = $top_frame->Button(-text => 'BOTTOM2')->pack(-side =>
'bottom', -anchor => 'e');

my $bttn4 = $top_frame->Button(-text => 'LEFT')->pack(-side => 'left');

my $bttn5 = $top_frame->Button(-text => 'RIGHT')->pack(-side =>
'right');


MainLoop();

Reply via email to