我正在尝试使用 Perl + Tkx 创建一个界面,该界面可以在单击按钮时运行外部命令。
有很多关于如何使用 Tk 模块的文档,但很少使用 Tkx。
我仍然找到了一些这样的,但我无法使其适用于我的示例。特别是这些帖子包括 Tkx::open、Tkx::configure 和 Tkx::fileevent 的使用......但我还没有想出如何将它们组合在一起。
这是我正在尝试的代码;当单击按钮并按下一个键终止子进程时,Perl 崩溃并出现错误Free to wrong pool 16389d0 not 328e448 at C:/Perl/lib/Tcl.pm line 433.
。
注意:我使用的是 ActivePerl 5.12.2。
use Tkx;
use strict;
my $mw = Tkx::widget->new(".");
my $button=$mw->new_ttk__button(-text => "Run", -command => [\&run_cmd, 0]);
$button->g_grid(-column => 0, -row => 0);
my $text = $mw->new_tk__text(-width => 32, -height => 16);
$text->configure(-state => "disabled");
$text->g_grid(-column => 0, -row => 1);
Tkx::MainLoop();
sub run_cmd {
if (fork()==0) {
system "pause";
exit 0;
}
}
谢谢