Reputation: 5
I'm using python tkinter to run tcl in python And there are two ways to run a tcl command:
import tkinter
root = tkinter.Tk()
root.eval("winfo exists .l0")
root.tk.call("winfo exists .l0")
They have the same meaning
But what's different? And if I haven't define a widget names .l0 and can I directly use
child = ".l0"
child.winfo_exists()
? Because python told me "str has no attribute winfo_exists"
Upvotes: 0
Views: 1379
Reputation: 386382
The difference is that call
passes each argument to tcl as a separate word, where eval
will evaluate a string by first parsing it and then executing it.
In other words, this:
root.eval("winfo exists .l0")
... is functionally identical to this:
root.tk.call("winfo", "exists", ".l0")
As for the error message 'str' object has no attribute 'winfo_exists'
, it means exactly that. "l0"
is the name of an object in the embedded tcl interpreter, but in python "l0"
is just a string and python strings don't have the attribute winfo_exists
.
Upvotes: 1