输入文本框模型

来源:互联网 发布:淘宝店铺运营软件 编辑:程序博客网 时间:2024/06/06 02:37
#!/usr/local/bin/perluse Tk;my $mw = new MainWindow; # Main Windowmy $frm_name = $mw -> Frame();my $lab = $frm_name -> Label(-text=>"Name:");my $ent = $frm_name -> Entry();  ###输入文本框my $but = $mw -> Button(-text=>"Push Me", -command =>\&push_button);my $textarea = $mw -> Frame(); #Creating Another Framemy $txt = $textarea -> Text(-width=>40, -height=>10);my $srl_y = $textarea -> Scrollbar(-orient=>'v',-command=>[yview => $txt]);my $srl_x = $textarea -> Scrollbar(-orient=>'h',-command=>[xview => $txt]);$txt -> configure(-yscrollcommand=>['set', $srl_y],-xscrollcommand=>['set',$srl_x]);$lab -> grid(-row=>1,-column=>1);$ent -> grid(-row=>1,-column=>2);$frm_name -> grid(-row=>1,-column=>1,-columnspan=>2);$but -> grid(-row=>4,-column=>1,-columnspan=>2);$txt -> grid(-row=>1,-column=>1);$srl_y -> grid(-row=>1,-column=>2,-sticky=>"ns");$srl_x -> grid(-row=>2,-column=>1,-sticky=>"ew");$textarea -> grid(-row=>5,-column=>1,-columnspan=>2);MainLoop;#This function will be executed when the button is pushedsub push_button {my $name = $ent -> get();$txt -> insert('end',"Hello, $name");}

0 0