#!/usr/bin/perl -w
use Tk;
use strict;

my $main=MainWindow->new;
my ($n1,$n2,$add,$eq,$result);
$main->title('Test');
$n1=$main->Entry(-width=>3);
$n2=$main->Entry(-width=>3);
$result=$main->Entry(-width=>4);
$add=$main->Label(
    -text=>'+');
$eq=$main->Button(
    -text=>'=',
    -command=>\&do_it);
foreach ($n1, $add, $n2, $eq, $result){
    $_->pack(-side=>"left", -fill=>"both");
}
MainLoop();

sub do_it(){
    my $sum=$n1->get()+$n2->get();
    $result->configure(-text=>$sum);
}

文章標籤
全站熱搜
創作者介紹
創作者 hechian 的頭像
hechian

卐只有兩面的盒子卍

hechian 發表在 痞客邦 留言(0) 人氣(251)