Tk

Feb. 2, 2013, 7:49 p.m.
#!/usr/bin/perl

use Tk;

sub Exit {
    exit(0);
}

sub showHelp {
    $tl = $root->Toplevel;
    $tl->title("Help");
    $tl->Label(-text => '(c) tswr')->pack();
}

$root = new MainWindow();
$root->title("hello Tk!");
$root->geometry("400x300");
$menu = $root->Menu;
$root->configure(-menu => $menu);
$filemenu = $menu->cascade(-label => '~File');
$filemenu->command(-label => 'E~xit', -command => \&Exit);
$helpmenu = $menu->cascade(-label => '~Help');
$helpmenu->command(-label => '~About', -command => \&showHelp);
$label = $root->Label(-text => "Hello Tk!");
$label->place(-anchor => 'nw', -y => 100, -x => 100);
$button = $root->Button(-text => 'exit', -command => \&Exit);
$button->pack(-anchor => 'w');
MainLoop();
comments powered by Disqus