Curses::UI - 如何关闭窗口?
按“后退”按钮时如何关闭win2?
#!/usr/bin/env perl
use warnings; use 5.012;
use Curses::UI;
$Curses::UI::debug = 0;
my $list = [ qw( Use the libraries from distribution instead of system ) ];
my %hash; my $y=0; my $x_1=0; my $width_1=14; my $x_2=16; my $width_2=30;
my $cui = new Curses::UI( -color_support => 1 );
my $win1 = $cui->add( "win1", 'Window', );
for my $entry ( @$list ) {
$win1->add( undef, 'TextEntry', -x => $x_1, -y => $y, -width => $width_1,
-text => $entry, -focusable => 0, -readonly => 1, );
$hash{$entry} = $win1->add( $entry, 'TextEntry', -x => $x_2, -y => $y,
-width => $width_2, -focusable => 1, -readonly => 0, );
$y++;
}
my $but1 = $win1->add( "addbutton1", 'Buttonbox',
-buttons => [ { -label => "< OK >", -onpress => \&add } ],
-x => 5, -y => $y + 2 );
sub add {
my $y = 0;
my $win2 = $cui->add( "win2", 'Window', );
for my $entry ( @$list ) {
my $input = $hash{$entry}->get();
$win2->add( undef, 'TextEntry', -x => $x_1, -y => $y, -width => $width_1,
-text => $entry, -focusable => 0, -readonly => 1, -bg => 'cyan' );
$win2->add( $y, 'TextEntry', -x => $x_2, -y => $y, -width => $width_2,
-text => $input, -focusable => 0, -readonly => 1, -bg => 'cyan' );
$y++;
}
my $but2 = $win2->add( "addbutton2", 'Buttonbox',
-buttons => [{ -label => "< Back >", ###
-onpress => sub{ $win1->focus() }}], -x => 5, -y => $y + 2 );
sub add2 { $win1->focus(); };
$win2->focus();
}
$cui->mainloop;
How could I close win2 when pressing the "Back"-button?
#!/usr/bin/env perl
use warnings; use 5.012;
use Curses::UI;
$Curses::UI::debug = 0;
my $list = [ qw( Use the libraries from distribution instead of system ) ];
my %hash; my $y=0; my $x_1=0; my $width_1=14; my $x_2=16; my $width_2=30;
my $cui = new Curses::UI( -color_support => 1 );
my $win1 = $cui->add( "win1", 'Window', );
for my $entry ( @$list ) {
$win1->add( undef, 'TextEntry', -x => $x_1, -y => $y, -width => $width_1,
-text => $entry, -focusable => 0, -readonly => 1, );
$hash{$entry} = $win1->add( $entry, 'TextEntry', -x => $x_2, -y => $y,
-width => $width_2, -focusable => 1, -readonly => 0, );
$y++;
}
my $but1 = $win1->add( "addbutton1", 'Buttonbox',
-buttons => [ { -label => "< OK >", -onpress => \&add } ],
-x => 5, -y => $y + 2 );
sub add {
my $y = 0;
my $win2 = $cui->add( "win2", 'Window', );
for my $entry ( @$list ) {
my $input = $hash{$entry}->get();
$win2->add( undef, 'TextEntry', -x => $x_1, -y => $y, -width => $width_1,
-text => $entry, -focusable => 0, -readonly => 1, -bg => 'cyan' );
$win2->add( $y, 'TextEntry', -x => $x_2, -y => $y, -width => $width_2,
-text => $input, -focusable => 0, -readonly => 1, -bg => 'cyan' );
$y++;
}
my $but2 = $win2->add( "addbutton2", 'Buttonbox',
-buttons => [{ -label => "< Back >", ###
-onpress => sub{ $win1->focus() }}], -x => 5, -y => $y + 2 );
sub add2 { $win1->focus(); };
$win2->focus();
}
$cui->mainloop;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
调用 $cui 上的删除方法。
Call the delete method on $cui.