#!/usr/bin/perl use strict; use warnings; use Tk; # Hauptfenster my $nw = MainWindow->new(); # Titel des Hauptfensters $nw->title ('Man-Machine Interfaces II - UE - BSP 3'); # MenĂ¼ my $mbar = $nw -> Menu(); $nw->configure (-menu => $mbar); my $file = $mbar->cascade (-label => "File", -underline => 0, -tearoff => 0); $file->command (-label => "Exit", -command => [$nw => 'destroy']); # Frames my $f1 = $nw->Frame()->pack (-side => 'top', -expand => 1, -fill => 'both'); my $f2 = $nw->Frame()->pack (-side => 'left', -expand => 1, -fill => 'both'); my $f3 = $nw->Frame()->pack (-side => 'bottom', -expand => 1, -fill => 'both'); # Buttons my $b1 = $f1->Frame (-borderwidth => 3, -relief => 'groove')->pack (-side => 'top', -expand => 1, -fill => 'both'); my @buttonwahl1 = ('1', '2', '3'); for my $a (0..$#buttonwahl1) { $b1->Button (-text => $buttonwahl1[$a], -command => sub {print "$buttonwahl1[$a]"})->pack (-anchor => 'e'); } my $b2 = $f2->Frame (-borderwidth => 3, -relief => 'groove')->pack (-side => 'left', -expand => 1, -fill => 'both'); my @buttonwahl2 = ('4', '5', '6'); for my $b (0..$#buttonwahl2) { $b2->Button (-text => $buttonwahl2[$b], -command => sub {print "$buttonwahl2[$b]"})->pack (-anchor => 'e'); } my $b3 = $f3->Frame (-borderwidth => 3, -relief => 'groove')->pack (-side => 'bottom', -expand => 1, -fill => 'both'); my @buttonwahl3 = ('7', '8', '9', '0'); for my $c (0..$#buttonwahl3) { $b3->Button (-text => $buttonwahl3[$c], -command => sub {print "$buttonwahl3[$c]"})->pack (-anchor => 'e'); } MainLoop();