|
use Tk;
# Hauptfenster my $mw = MainWindow->new();
#Textfeld für die Eingabe: $mw->Label(-text=>'Eingabe:')->pack(); my $eingabe = $mw->Text(-width=>30,-height=>5)->pack();
#Textfeld für die Ausgabe:
$mw->Label(-text=> 'Ausgabe:')->pack(); my $ausgabe = $mw->Text(-width=>30,-height=>5)->pack();
#Frame für die Buttons my $bottom_frame = $mw->Frame()->pack(-side=>'bottom', -pady=>5);
$bottom_frame->Button( -text=>'Alles zeigen', -command=>\&allesZeigen)->pack(-side=>'left'); $bottom_frame->Button( -text=>'Erste Zeile', -command=>\&ersteZeile)->pack(-side=>'left'); $bottom_frame->Button( -text=>'Alles löschen', -command=>\&loeschen)->pack(-side=>'left'); MainLoop;
sub allesZeigen{ $ausgabe->configure(-state=>'normal'); $ausgabe->delete('1.0','end'); my $text_string = $eingabe->get('1.0','end'); $ausgabe->insert('end',$text_string); $ausgabe->configure(-state=>'disabled'); } sub ersteZeile{ $ausgabe->configure(-state=>'normal'); $ausgabe->delete('1.0','end'); my $text_string = $eingabe->get('1.0','2.0'); $ausgabe->insert('end',$text_string); $ausgabe->configure(-state=>'disabled'); } sub loeschen{ $ausgabe->configure(-state=>'normal'); $ausgabe->delete('1.0','end'); $ausgabe->configure(-state=>'disabled'); }
|