Tk2portableTk is Perl module that contains a tutorial about how to make your Tk source portable to other interpreted languages.
PortableTk is an attempt to make Tk useful from other languages. Currently tk4.0 runs under Perl using this approach. Below, Lang is the notation for an external language to which PortableTk glues Tk code.
The main problem with using the code developed for TCL with different languages is the absence of data types: almost anything is char*. It makes automatic translation hopeless. However, if you typedef several new symbols to be char*, you can still use your code in TCL, and it will make the automatic translation possible.
Another problem with the approach that "everything is a string" is impossibility to have a result that says "NotApplicable" without setting an error. Thus different Tk command return different string values that mean "error happened", like "", " " or "??". Other languages can be more flexible, so in portableTk you should inform the compiler that what you want to return means "error" (see "Setting variables").
Currently PortableTk uses several different approachs to simplify translation: several TCL functions that are especially dangerous to use are undefined, so you can easily find places that need to be updated to use Language-independent functions based on compiler warnings. Eventually a way to use these Language-independent functions under proper TCL will be also provided. The end of this document provides a starting point for such a project.
Structure of pTk, porting your code
pTk, that is a port of Tk, is very special with respect to porting of other code to portableTk. The problem is that currently there is very little hope to merge the modifications back into Tk, so a special strategy is needed to maintain this port. Do not use this strategy to port your own code.
pTk is produced from Tk via a two-step process: first, some manual editing (the result is in the subdirectory mTk), and second, automatic conversion by the munge script (written in Perl). Thus the subdirectory pTk/mTk contains code with minimal possible difference from the virgin Tk code, so it is easier to merge(1) the differences between Tk versions into modified code.
It looks like the strategy for a portable code should be exactly opposite: starting from TCL-based code, apply munge, and then hand-edit the resulting code. Probably it is also possible to target your code to portableTk from scratch, since this will make it possible to run it under a lot of Languages.
The only reason anyone would like to look into contents of pTk/mTk directory is to find out which constructs are not supported by munge. On the other hand, pTk directory contains code that is conformant to portableTk, so you can look there to find example code.
munge is the script that converts most common Tk constructs to their portableTk equivalent. For your code to qualify, you should follow Tk conventions on indentation and names of variables, in particular, the array of arguments for the ...CmdProc should be called argv.