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?

How about Tkinter.tcl?

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()

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.