programming-examples/perl/GUI/Show a dialog box.pl

34 lines
542 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
use Tk;
$main = MainWindow->new();
$dialog = $main->DialogBox(
-title => "Dialog box",
-buttons => ["OK", "Cancel"]
);
$entry = $dialog->add(
"Entry", -width => 40
)->pack;
$main->Button(
-text => "Show dialog box",
-command => \&show
)->pack;
$text1 = $main->Text (
-width => 40,
-height => 2
)->pack();
MainLoop;
sub show
{
$result = $dialog->Show;
if ($result eq "OK") {
$text1->delete('1.0','end');
$text1->insert('end', $entry->get);
}
}