How to run commands on same TCL shell using Python
Question: I am having all the libraries written in TCL. I want to create a GUI in Python
which will have few buttons and other options. In the start TCL shell will
open. When I will click the buttons, respective commands will be executed on
the TCL shell.

Is it possible to fire commands on the same shell of TCL without closing TCL
shell.

I searched google and find `Tkniter` module in Python but it will open TCL
shell everytime I need to execute command.


Answer: You can certainly use Tkinter to run a series of commands in the same Tcl
interpreter:

    
    
    Python 2.7.9 (default, Feb 28 2016, 05:52:45) [C] on sunos5
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import Tkinter
    >>> root = Tkinter.Tk()
    >>> root.tk.eval('set msg "hello world"')
    'hello world'
    >>> root.tk.eval('string length $msg')
    '11'
    >>> root.tk.eval('foreach x {1 2 4} {puts "$msg $x"}')
    hello world 1
    hello world 2
    hello world 4
    ''
    >>> 
    

\- here the variable msg is set in one command and its value is used in later
commands, which would not work if we were creating a new interpreter for each
command. If you don't want the Tk window that gets created, just run
`root.tk.eval('wm withdraw .')` to hide it.

If this doesn't answer your question you had better explain what else it is
that you need :-)

