0

Hi,

I want to execute a tcl command with a python method. I don't really know how this works.
This is my tcl command:

<object> config -<parameter>

Now I want a python method, that should look like this:

def config(config_obj, parameter):
    #code which executes the tcl command

Do you know how this works?

3
Contributors
3
Replies
6
Views
4 Years
Discussion Span
Last Post by Tortura
0

The Python GUI toolkit Tkinter is based on TCL and contains a TCL interpreter ...

# it is simple to run tcl scripts via Tkinter
# tested with Python273

import Tkinter

root = Tkinter.Tk()

tcl_script = """
# this is a tcl script
label .label -text "Hello World! in tcl script"
pack .label
button .button -text "Quit" -command {destroy .}
pack .button
"""

# call the Tkinter tcl interpreter
root.tk.call('eval', tcl_script)
root.mainloop()
0

Thanks for your help. I read something about Tkinter and know that I have to import this for using tcl commands. Your code shows me how Tkinter works, thats pretty nice, but can you help me with my problem to call the tcl command, I wrote in the first post?

Thanks

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.