Leser: 28
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
use strict; use Tk; my $MW= MainWindow->new; $MW -> configure(-bg => 'white'); # Frames-Zeilen my $F1 = $MW->Frame(-width => 600,-height => 200)->pack(-side => 'top',-anchor => "nw"); my $F2 = $MW->Frame(-width => 600,-height => 100)->pack(-side => 'top',-anchor => "nw"); my $F3 = $MW->Frame(-width => 600,-height => 30)->pack(-side => 'top',-anchor => "nw"); # Zellen in den Zeilen my $FA = $F1->Frame(-width => 200,-height => 200,-bg => 'yellow')->pack(-side => 'left',-anchor => "nw"); my $FB = $F1->Frame(-width => 400,-height => 200)->pack(-side => 'left',-anchor => "nw"); my $FC = $F2->Frame(-width => 200,-height => 100)->pack(-side => 'left',-anchor => "nw"); my $FD = $F2->Frame(-width => 400,-height => 100, -bg => 'yellow')->pack(-side => 'left',-anchor => "nw"); my $FE = $F3->Frame(-width => 600,-height => 30)->pack(-side => 'left',-anchor => "nw"); #Label #my $lbl_1 = $FD->Label (-text=>"Projectname:\n\nProjectpath:\n\nconfig files exist:")->pack(); MainLoop;
2009-08-12T13:37:31 NixIsFixUnd lohnt es sich damit eine feste Struktur für MainWindow zu erzeugen?
Oder gibt es noch einen besseren Weg?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
use strict; use warnings; use Tk; my $mw = MainWindow->new(); # erstelle eine tabelle: foreach my $row (0..5){ foreach my $column (0..5){ $mw->Label( -text => "$row : $column", -relief => 'groove', -bd => 2, )->grid(-row => $row, -column => $column); } } Tk::MainLoop();
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
use strict; use warnings; use Tk; my $out; my $top = MainWindow->new(-title=>'Tk happy hour',-bg=>'white'); my $frame_top = $top->Frame->pack(-fill=>'x'); my $frame_middle = $top->Frame->pack(-expand=>'1',-fill=>'both'); my $frame_bottom = $top->Frame->pack(-expand=>'1',-fill=>'both'); my $frame_middle_left = $top->Frame->pack(-in=>$frame_middle,-side => 'left',-fill=>'both'); my $frame_middle_right = $top->Frame->pack(-in=>$frame_middle,-expand=>'1',-fill=>'both'); my $yellowtopleftlabel = $top->Label(-bg => 'yellow',-width => 32,-height => 15)->pack(-in=>$frame_top,-side=>'left'); my $graytoprightlabel = $top->Label(-width => 64,-height => 15)->pack(-in=>$frame_top,-fill=>'x'); my $graymiddleleftlabel = $top->Label(-width => 32,-height => 7)->pack(-in=>$frame_middle_left,-expand=>'1',-fill=>'y'); my $outlabel = $top->Label(-textvariable=>\$out,-bg => 'yellow',-font=>'Courier 10',-justify=>'left',-anchor=>'nw')->pack(-in=>$frame_middle_right,-expand=>'1',-fill=>'both'); my $graybottomlabel = $top->Label(-width => 64,-height =>2)->pack(-in=>$frame_bottom,-expand=>'1',-fill=>'both'); my $thisname='Moorhuhn'; my $thispath='C:\Programme\Moorhuhn'; my $thisconfig='yes'; $out=sprintf ("%-20s %s\n%-20s %s\n%-20s %s\n","Projectname:",$thisname,"Projectpath:",$thispath,"config files exist:",$thisconfig); MainLoop;