Embed tclsh in tk

103 views Asked by At

Is it possible to embed tclsh in Tk? I'm trying to send commands from a user interface made by tk and observe its results.

If so, could you help to pose some simple codes for this? Thank you very much.

1

There are 1 answers

3
TM90 On

You should take a look at the interp command to create and manipulate tcl interpreters:

http://wiki.tcl.tk/1477

You should be able to first create a interpreter this way and evaluate strings from your Tk Application.

  1. create a interpret
  2. Get the to evaluated string from your Tk application
  3. evaluate the string in this interpreter

A minimal example to create an interpreter and evaluate a a string in it:

interp create a
set str "puts \"Hello World!\""
interp eval a $str