Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The Simplest Steps to Converting TCL TK to a Stand Alone Application

Tags:

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.

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.

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?

like image 826
DFM Avatar asked Sep 01 '09 14:09

DFM


People also ask

Which of the following are important features of tcl commands?

Tcl - Commands The advantage with these Tcl commands is that, you can define your own implementation for any of these commands to replace the original built-in functionality. Each of the Tcl commands validates the input and it reduces the work of the interpreter.

How do you execute a command in tcl?

Print the file_path and make sure it is not empty. please update your Q with the actual tcl exec call. It looks like you may need to add spaces so your cmd looks like a cmd-line invocation, ie. cat /path/to/file | grep ...

How do I set environment variable in tcl Mcq?

In side tcl script, you can simply do setenv as, setenv AUTOTEST="/auto/isbutest/frt" . if you want to set a variable, use set VARNAME "/auto/isbutest/frt" . if you want to get any environment variable, use $::env(AUTOTEST) .


1 Answers

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 

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 

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 

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.

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

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.

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

like image 180
Bryan Oakley Avatar answered Nov 08 '22 22:11

Bryan Oakley