开发者

how to get textfield data in win32-gui perl

hi i want to store textfield data in a variable but my code is not working here is my code

use Win32::GUI qw<>;

my $W1 = Win32::GUI::Window->new(
 -name  => "W1",
 -title => "First Window",
 -pos   => [ 100, 100 ],
 -size  => [ 300, 200 ],
);

$W1->AddButton(
 -name => "ButtonW1",
 -text => "Enter Chipname",
 -pos  => [ 87, 100 ],
 #-ok  => 1,
);

 $W1->AddTextfield(
  -name    => "chipfield",
  -left    =>  20,
  -top     =>  40,
  -width   => 250,
  -height  => 20,
   #  -prompt => ["Mix ",30],
  );

$W1->Show();
Win32::GUI::Dialog();
exit(0);


sub W1_Terminate { return -1; }

sub ButtonW1_Click {
    my $chipname = $W1->chipfield->Text();
    print $chipname;
}

please help me where is problementer code her开发者_高级运维e


Looks like a Buffering problem. Add $|=1; before the print $chipname; statement and everything will be fine like so:

my $chipname = $W1->chipfield->Text();
$|=1;
print $chipname;

Or do what axeman suggested by changing

print $chipname;

to

print $chipname,"\n";

You might also want to take a look at this article: Suffering from Buffering?


Looks like a problem of destroy pocessing of "Win32::GUI::Window Class"

my $W1 = Win32::GUI::Window->new(
 -name  => "W1",
 -title => "First Window",
 -pos   => [ 100, 100 ],
 -size  => [ 300, 200 ],
);
...

$W1->Show();
Win32::GUI::Dialog();
undef $W1;       <-----Addtion line
exit(0);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜