Perl Tk 模块有哪些缺点?

发布于 2024-08-27 15:11:38 字数 44 浏览 9 评论 0原文

与在 Perl 中创建 GUI 的其他解决方案相比,Tk 模块有哪些缺点?

What are the disadvantages of the Tk module compared to other solutions to create a GUI in Perl?

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

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

发布评论

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

评论(2

虚拟世界 2024-09-03 15:11:38

我最近浏览了 Perl 的各种 gui 模块,这是我的总结(免责声明:最终我发现现有模块都不能满足我的需求,所以我开始编写自己的 gui 工具包)。

Tk - 工作起来很不错,界面也非常漂亮。 gui 本身看起来有点过时,并且没有利用任何操作系统的本机小部件(如文件选择器)。在大多数系统上,需要安装 C 编译器。

Wx - 难以使用,不那么糟糕的界面。大型程序几乎需要 GUI 构建器来跟踪所有内容。对操作系统级小部件的支持是混合的。在我看来,比 Tk 更好看。涉及编译,需要安装多个库,在 Windows 上运行可能比较困难。程序的组装非常程序化,并不能清楚地映射到程序的实际外观。

Qt - 最后我发现这个模块或多或少被放弃了,只支持 Qt3。我没有尝试安装它,但我想它需要一个编译器。

Prima - 与 Tk 类似,它的外观过时。需要编译器。

W32::GUI - 我很早就排除了这一点,因为它不是跨平台的。

XUL::Node / POE::XUL::Node - 包含 C 代码的相当重的依赖树。似乎没有维护,我安装它的经历很复杂。 Windows 是不行的,OSX 也是不行的,它在 OpenSUSE 上的功能有限。它还仅支持 XUL 语言的一个子集。

我发现现有的 GUI 工具包都没有能够让您轻松地将应用程序分发给最终用户。期望程序员跳过解决库依赖关系和编译代码的麻烦是可以的,但最终用户不会这样做。所以我的第一个要求是纯 Perl。

其次,几乎所有现有的 GUI 工具包都迫使您以非常程序化的方式工作:创建一个容器。为容器创建一个打包器。创建一个对象。设置该对象的属性。将对象添加到打包器中。运行加壳器来填充容器对象。重复。

相反,我发现嵌套设计(如 HTML)更容易遵循,原因有两个。首先,由于对象是嵌套的,因此无需命名所有内容(label_456、label_457...)。其次,程序的结构反映了显示内容的结构。

因此,我开始了 XUL::Gui 的工作,并且进展顺利。它是纯 Perl 的,仅依赖于核心模块,易于安装。它有一个外部要求,即安装最新的 (3+) Firefox 副本。它使用熟悉的 Web 开发设计模式以及 CSS 样式的嵌套标签。它肯定达到了您可以用它编写功能齐全的单窗口应用程序的水平。

希望这可以帮助您找出最适合您的项目的工具包。

I toured the various gui modules for Perl recently, and here is my summary (disclaimer: ultimately I found that none of the existing modules met my needs so I started writing my own gui toolkit).

Tk - Decent to work with and the interface is very perlish. The gui itself is a bit dated looking, and doesnt take advantage of any of the operating system's native widgets (like filepickers). On most systems it will require a C compiler to install.

Wx - Difficult to work with, un-perlish interface. Large programs almost require a gui builder to keep track of everything. Support for os level widgets is mixed. Nicer looking than Tk IMO. Compilation is involved, requires installing several libraries, can be difficult to get running on windows. The assembly of programs is very procedural, and does not map cleanly to what the program will actually look like.

Qt - last I looked this module was more or less abandoned and only supports Qt3. I didn't try to install it, but i imagine it needs a compiler.

Prima - Similar to Tk it has a dated appearance. Requires a compiler.

W32::GUI - I ruled this out early since it is not cross platform.

XUL::Node / POE::XUL::Node - rather heavy dependency tree that includes C code. Seems unmaintained and I had mixed experiences getting it to install. Windows was a no go, OSX was a no go, it had limited functionality on OpenSUSE. It also only supports a subset of the XUL language.

I found that none of the existing gui toolkits made it easy enough to distribute your application to end users. It is ok to expect programmers to jump through the hoops of resolving library dependencies and compiling code, but end users aren't going to do that. So the first requirement I had was to be pure Perl.

Secondly, nearly all of the existing gui toolkits force you to work in a very procedural manner: Create a container. Create a packer for the container. Create an object. Set properties on that object. Add the object to the packer. Run the packer to fill the container object. Repeat.

Instead, I find that nested design (like HTML) is easier to follow for two reasons. First off, since objects are nested, there is no need to name everything (label_456, label_457...). Secondly, the structure of the program mirrors the structure of what is displayed.

So I started work on XUL::Gui, and its been coming along rather well. It is pure Perl, and only depends on core modules for ease of installation. It has one external requirement, which is that a recent (3+) copy of Firefox is installed. It uses the familiar design pattern of web development with nested tags styled with CSS. It is certainly at a level where you could write fully featured single window applications with it.

Hopefully this helps you to figure out which toolkit is best for your project.

够运 2024-09-03 15:11:38

Tk 已经很长时间没有开发了。 ActiveState 现在建议使用他们的 Tkx 工具包进行开发,该工具包在 TclTk 上提供了一个薄层。这意味着主题小部件是可能的。但是,与许多其他 GUI 工具包相比,TclTk 仍然相当原始。

我还没有尝试过 XUL:Gui,但这似乎是可行的方法。

Tk has not been developed in a very long time. ActiveState now recommends development with their Tkx toolkit, which provides a thin layer over TclTk. It means that themed widgets are possible. But, TclTk is still quite primitive compared with many other GUI toolkits.

I haven't tried XUL:Gui but it seems the way to go.

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