1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#!/usr/bin/perl use warnings; use strict; use Tk; my $text = ""; my $mw = new MainWindow; my $entry = $mw->Entry(); $entry->insert('end', "Dies ist ein Text."); $entry->focus(); $entry->pack(-padx=>20,-pady=>20); my $button = $mw->Button(-text=>"Ok",-command=>sub{$text=$entry->get();$mw->destroy()}); $button->pack(-padx=>20,-pady=>20); MainLoop; print "Text ist: $text\n";