我刚开始 Perl Tk 并查看了一些教程,但我遇到了问题。当我单击一个按钮时,它会在条目小部件上显示我想要的标量。它可以工作,但是当我再次单击时,它会保留条目上所写的内容。所以我有两个你好。我知道它来自 insert(0, "Hello") 但我不知道该放什么而不是 0。
#!/usr/local/bin/perl
use Tk;
my $mw = MainWindow->new;
$mw->geometry("500x350+0+0");
$mw->title("Report Information about a Protein of Interest");
my ($bite) = $mw -> Label(-text=>"Enter the uniprot accession number:")->grid(-row => 0, - column => 0);
my ($ent) = $mw->Entry()->grid(-row => 0, - column => 1, -columnspan => 2, -sticky => 'nsew');
$ent2 = $mw->Button(-text=> "Search", -command => \&push_button)->grid(-row => 1, - column => 0);
MainLoop;
#This is executed when the button is pressed
sub push_button {
$ent -> insert(0,"Hello, ");
}