The daVinci Tcl/Tk Interface can be used by application programmers to create their own application specific windows. The daVinci Tcl/Tk interface is able to execute any Tcl 7.4/Tk 4.0 script in the same way as a wish shell would do. So, the application program does not need to start its own wish (or another interpreter) to use Tcl/Tk, because "daVinci is the wish". This way, the application does not need to deal with another X-Window toolkit to realize its graphical front-end. All it has to do to implement a graphical user interface is sending API commands and Tcl/Tk scripts to the daVinci API.
Tcl/Tk scripts can either be sent to daVinci with API command tcl(eval(string)), whereby string is the Tcl/Tk script, or loaded from file with API command tcl(eval_file(filename)). Command tcl(eval(string)), i.e. sending the complete Tcl/Tk script via pipe, is only useful for small scripts or Tcl/Tk function calls, because the string argument has to fulfill the conventions for API strings, especially the double quote characters have to be escaped (i.e. \") and newline or return characters are not allowed (use \n instead). This restriction is not required for Tcl/Tk scripts loaded from file with API command tcl(eval_file(filename)). For both commands, the result of the Tcl/Tk script will be immediately returned to the application with answer tcl_answer(...) as soon as the script is executed.
A possible scenario for using the Tcl/Tk interface is to save a script of Tcl/Tk functions in a file and execute it with API command tcl(eval_file(filename)) at startup time of daVinci. During runtime, the particular functions can be called by sending API command tcl(eval(string)).
Note: If you have installed Tcl7.5/Tk4.1 or higher, then you have to set the following environment variables in the shell before starting daVinci and using its Tcl/Tk interface.
Note: daVinci's user interface and graph visualization cannot be manipulated with the Tcl/Tk interface, so daVinci is not a Tcl object in the common sense. The daVinci system can only be accessed by using the commands of the API.
Example:
tcl(eval("button .b -text Hello -command {daVinci tcl_answer Pressed} ; pack .b"))
Note: It is currently not possible to use Tcl delimiters (i.e. '{' and '}') inside the string argument of command tcl_answer. E.g. "...-command {daVinci tcl_answer {Pressed}}" is not allowed in the example above, although it is a valid Tcl expression.
Example:
tcl(eval("button .b -text Clear -command {daVinci command menu(file(new))} ; pack .b"))
Sends a Tcl/Tk script string to daVinci's
Tcl/Tk interface
and waits for the result (i.e. return value) of this script which can be
found in the string of the API answer tcl_answer(...), sent back
to the application as soon as the script has finished.
daVinci is blocked as long as the Tcl-script is executed.
Note: The Tcl/Tk script in string must not contain return or
newline characters and all double quotes inside the string need to be
escaped (i.e. \").
tcl(eval_file(filename))
-> Returns answer tcl_answer(...)!
Same as API command tcl(eval(...)) above, but the Tcl/Tk script is read from the specified file rather than taken from the string parameter. So, the Tcl/Tk script does not need to be transfered via pipe. Use this API command for large scripts or if you cannot fulfill the API convention for strings (i.e. no return/newline characters and no unescaped double quotes in the Tcl/Tk script).