#!perl -w use Encode qw(decode encode); use Tk; use strict; { # ================= # define MainWindow # ================= my $mw; $mw=MainWindow->new(); $mw->title('sample_003'); $mw->optionAdd('*font'=>['Consolas',10]); # ================================================ # step1: define and pack main frames in MainWindow # ================================================ my $frm; $frm->[0]=$mw->Frame(); $frm->[0]->pack(-side=>'top'); $frm->[1]=$mw->Frame(); $frm->[1]->pack(-side=>'top'); $frm->[2]=$mw->Frame(); $frm->[2]->pack(-side=>'top'); # ============================================= # step2: define and pack sub frames in frm->[1] # ============================================= my $frms; $frms->[0]=$frm->[1]->Frame(); $frms->[0]->pack(-side=>'left'); $frms->[1]=$frm->[1]->Frame(); $frms->[1]->pack(-side=>'left'); # ============================ # step3: set widgets in frames # ============================ my $wgt; $wgt->[0]=$frm->[0]->Button(-text=>'widget0'); $wgt->[0]->pack(-side=>'top'); $wgt->[1]=$frms->[0]->Button(-text=>'widget1'); $wgt->[1]->pack(-side=>'left'); $wgt->[2]=$frms->[1]->Button(-text=>'widget2'); $wgt->[2]->pack(-side=>'right'); $wgt->[3]=$frms->[1]->Button(-text=>'widget3'); $wgt->[3]->pack(-side=>'right'); $wgt->[4]=$frm->[2]->Button(-text=>'widget4'); $wgt->[4]->pack(-side=>'bottom'); $wgt->[5]=$frm->[2]->Button(-text=>'widget5'); $wgt->[5]->pack(-side=>'bottom'); # loop MainLoop(); }