在框架而不是终端上获取输出 (Perl-Tk)
#!/usr/local/bin/perl
use Tk;
# Main Window
$mw = new MainWindow;
$label = $mw -> Label(-text=>"Hello folks") -> pack();
$button = $mw -> Button(-text => "Click here to Flush rules",
-command =>\&flush) -> pack();
MainLoop;
sub flush {
$mw->messageBox(-message=>"Initiating flushing.. click on OK button");
system ("iptables -L");
system ("iptables -F");
system ("iptables -L");
}
我编写了这段代码,它的作用是,当用户单击按钮时,会出现一个消息框
然后当我单击“确定”按钮时,它会调用子例程 flush
,然后输出显示在终端上,如下所示:
我希望它出现在同一个消息框中。我该怎么做呢?
#!/usr/local/bin/perl
use Tk;
# Main Window
$mw = new MainWindow;
$label = $mw -> Label(-text=>"Hello folks") -> pack();
$button = $mw -> Button(-text => "Click here to Flush rules",
-command =>\&flush) -> pack();
MainLoop;
sub flush {
$mw->messageBox(-message=>"Initiating flushing.. click on OK button");
system ("iptables -L");
system ("iptables -F");
system ("iptables -L");
}
I made this code and what it does is that when a user click on the Button a message box appears
Then when I click on OK button it calls the subroutine flush
and then the output is shown on terminal like this:
I want it to be appear on the same message box. How can I do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在 perlmonks 得到了这个问题的答案。
perlmonks 的帖子链接是-> http://www.perlmonks.org/index.pl?node_id=920414
I have got the answer of this question at perlmonks.
The link of the post at perlmonks is-> http://www.perlmonks.org/index.pl?node_id=920414