将 TCL TK 转换为独立应用程序的最简单步骤 [英] The Simplest Steps to Converting TCL TK to a Stand Alone Application

查看:33
本文介绍了将 TCL TK 转换为独立应用程序的最简单步骤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在遇到 C#、ASP.NET、MS Access、Linux 和 Mono 的主要兼容性问题后,我决定使用跨平台、开源且与嵌入式数据库兼容的语言进行编程兼容很多平台.我将选择范围缩小到 TCL.

After running into major compatitiblity problems with C#, ASP.NET, MS Access, Linux, and Mono, I've decided to program in a language that is cross-platform, open source, and compatible with embedded databases that are also compatible with many platforms. I narrowed my choice down to TCL.

在我使用 TCL 开始一个示例应用程序之前,我想看看创建一个独立的应用程序是多么容易.我购买了一本名为TCL 和 TK 中的实用编程"的书,下载了 TCLkit 和 FreeWrap,但我在寻找将 TK (Wish) 中的 TCL 转换为独立应用程序的方法论方法时遇到了麻烦.

Before I began a sample application with TCL, I wanted to see how easy it was to create a stand alone application. I purchased a book entitled "Practical Programming in TCL and TK", downloaded TCLkit, and FreeWrap, yet I am having troubles finding a methodological way to convert TCL in TK (Wish) into a standalone application.

是否有人能够提供将 TCL TK 脚本(例如带有文本的标签)转换为应用程序或具有非常直接解释的网络资源的简单步骤?

Would anyone be able to provide simple steps towards converting a TCL TK script, such as a label with text on it, into an application, or a web resource that has a pretty straight forward explanation?

推荐答案

要构建一个星际包,您需要 a) tclkit 运行时,b) sdx.kit.您还需要一个basekit",该可执行文件将与您的 tcl 代码一起包装.对于本示例,我假设您正在为正在运行的同一平台创建一个应用程序.您可以通过简单地将 tclkit(或 Windows 上的 tclkit.exe)复制到另一个名称来创建 basekit,例如basekit"

To build a starpack you need a) a tclkit runtime, b) sdx.kit. You also need a "basekit", the executable that will be wrapped with your tcl code. For this example I'll assume you're creating an application for the same platform you are running on. You can create a basekit by simply copying tclkit (or tclkit.exe on windows) to another name, such as "basekit"

% ls
sdx.kit tclkit
% cp tclkit basekit
% ls
basekit sdx.kit tclkit

现在,创建您想要包装到可执行文件中的代码.约定是使用您的应用程序名称和后缀.vfs"(用于虚拟文件系统")创建一个目录,然后在该目录中创建一个名为main.tcl"的文件:

Now, create the code that you want to have wrapped into an executable. The convention is to create a directory with the name of your app and the suffix ".vfs" (for 'virtual file system'), then create a file named 'main.tcl' in that directory:

% mkdir myapp.vfs
% cat > myapp.vfs/main.tcl
package require Tk
label .l -text "Hello, world"
pack .l
^D
% ls myapp.vfs
main.tcl

现在进行包装:为此您需要 sdx.kit 文件.假设它和 tclkit(或 tclkit.exe)在您当前的工作目录中,您可以像这样包装您的应用程序:

Now to do the wrapping: for this you'll need the sdx.kit file. Assuming it and tclkit (or tclkit.exe) are in your current working directory, you wrap your app like this:

% ./tclkit sdx.kit wrap myapp -runtime basekit
1 updates applied
% ls 
basekit myapp myapp.vfs sdx.kit tclkit

wrap 命令知道当你给它参数myapp"时它应该包装 myapp.vfs 的内容,并且它应该在那个目录中寻找一个名为main.tcl"的文件作为程序入口点.你可以把你想要的任何其他文件放在那个目录中,它们都会被包装,包括特定于平台的二进制文件、图像文件和任何你想捆绑的东西.

The wrap command knows when you give it the argument "myapp" that it should wrap the contents of myapp.vfs, and that it should look for a file named "main.tcl" in that directory to be the program entry point. You can put whatever other files you want in that directory and they will all be wrapped, including platform-specific binary files, image files and anything else you want bundled up.

您现在有一个可执行文件myapp",即打包的应用程序.

You now have an executable file, 'myapp', that is the wrapped application.

如果您有不同架构的 tclkit,您可以使用它们(用目标架构的套件替换命令行上的basekit")为其他平台交叉编译.

If you have the tclkits for different architectures you can use them (replacing 'basekit' on the command line with the kit for the target architecture) to cross-compile for other platforms.

有关更多信息,请参阅 Tcl'ers Wiki

For more information see How to create my first Starpack on the Tcl'ers Wiki

这篇关于将 TCL TK 转换为独立应用程序的最简单步骤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆