尝试从使用 tkx (Tcl/tk) 的 Perl 脚本创建独立应用程序

发布于 2024-08-02 13:39:59 字数 230 浏览 4 评论 0原文

这是我的规格: OS X 老虎 珀尔 5.8 使用与 ActiveTcl v8.5 捆绑的 Tkx

我已经使用 PAR/pp 成功创建了具有上述配置的独立应用程序,但这不是一个完全令人满意的解决方案:

  • 仍然需要安装 Tcl/Tk
  • 在 Tcl/Tk 窗口中打开 默认菜单
  • 每次运行应用程序时,

都会打开终端是否有其他途径可以绕过这些问题?

Here are my specs:
OS X Tiger
Perl 5.8
Using Tkx bundled with ActiveTcl v8.5

I've successfully created a standalone app with the above configuration using PAR/pp, but it's not a completely satisfactory solution:

  • still requires Tcl/Tk to be installed
  • opens up in a Tcl/Tk window with a default menu
  • opens Terminal every time I run the application

Is there another route I can take that would bypass these issues?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

独夜无伴 2024-08-09 13:39:59

如果您使用 ActivePerl,它应该与 Tcl 和 Tk 的共享对象捆绑在一起。这些文件是 Tcl.so 和 tkkit.so(Windows 上为 Tcl.dll 和 tkkit.dll)。您需要使用 -l 选项配置 pp 以将它们与您的独立可执行文件捆绑在一起。例如(在 Windows 上):

-l C:/Perl/lib/auto/Tcl/tkkit.dll
-l C:/Perl/lib/auto/Tcl/Tcl.dll

不幸的是 PAR 无法将共享对象解压到正确的位置以便 Tkx 应用程序找到它们。您可以通过在加载 Tkx 之前设置 $ENV{PERL_TCL_DL_PATH} 来解决此问题。要使应用程序在有或没有 PAR 的情况下都可用,请使用 BEGIN 块来检测它何时在 PAR 下运行:

use strict;
use warnings;
use File::Spec::Functions;

BEGIN {
    if (exists $ENV{PAR_PROGNAME}) {
        use Config ();
        $ENV{PERL_TCL_DL_PATH} = catfile(
            $ENV{PAR_TEMP},
            'tkkit.' . $Config::Config{dlext},
        );
    }
}

use Tkx;
# remainder of script...

pp 具有 -g (或 --gui) 选项来构建没有控制台窗口的应用程序,但它仅适用于 Windows。我不知道是否有办法在 OS X 上隐藏控制台。

至于在带有默认菜单的 Tcl/Tk 窗口中打开应用程序,我不知道。我怀疑这是因为您使用的是 ActiveTcl 安装而不是与 ActivePerl 捆绑在一起的共享对象。

If you're using ActivePerl it should come bundled with shared objects for Tcl and Tk. The files are Tcl.so and tkkit.so (Tcl.dll and tkkit.dll on Windows). You'll want to configure pp to bundle them with your self-contained executable using the -l option. For example (on Windows):

-l C:/Perl/lib/auto/Tcl/tkkit.dll
-l C:/Perl/lib/auto/Tcl/Tcl.dll

Unfortunately PAR doesn't unpack shared objects in the right place for Tkx applications to find them. You can get around this by setting $ENV{PERL_TCL_DL_PATH} before loading Tkx. To make an application that is usable either with or without PAR, use a BEGIN block to detect when it's being run under PAR:

use strict;
use warnings;
use File::Spec::Functions;

BEGIN {
    if (exists $ENV{PAR_PROGNAME}) {
        use Config ();
        $ENV{PERL_TCL_DL_PATH} = catfile(
            $ENV{PAR_TEMP},
            'tkkit.' . $Config::Config{dlext},
        );
    }
}

use Tkx;
# remainder of script...

pp has a -g (or --gui) option to build applications without a console window but it only works on Windows. I don't know if there's a way to hid the console on OS X.

As for the application opening in a Tcl/Tk window with a default menu, I don't know. I suspect that's because you're using the ActiveTcl installation instead of the shared objects bundled with ActivePerl.

み青杉依旧 2024-08-09 13:39:59

ActiveState Perl 开发工具包具有将 Tkx 脚本绑定为正确的 OS X 应用程序的额外知识。您可以尝试一下 http://www.activestate.com/perl-dev-kit< /a>.

弹出的控制台与 Tk 中的启发式方法有关,它试图确定您是否正在交互式运行(并且在您的情况下显然是错误的)。您始终可以通过以下方式抑制其显示:

Tkx::catch("console hide");

在 OS XI 上还建议:

Tkx::set("::tk::mac::useThemedToplevel" => 1);

The ActiveState Perl Dev Kit has the extra knowledge to bind Tkx scripts as proper OS X apps. You can give it a try at http://www.activestate.com/perl-dev-kit.

The console popping up has to do with heuristics in Tk that are trying to determine if you are running interactively or not (and evidently getting it wrong in your case). You can always suppress its display with:

Tkx::catch("console hide");

On OS X I also recommend:

Tkx::set("::tk::mac::useThemedToplevel" => 1);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文