我想从Tcl字典中得到一个python字典tk.呼叫. 这有可能吗?你知道吗
示例:
import tkinter
desiredDict = {"first": "Foo", "second": "Bar", "third": "Baz"}
tk = tkinter.Tcl()
tk.call("set", "data(first)", "Foo" )
tk.call("set", "data(second)", "Bar" )
tk.call("set", "data(third)", "Baz" )
foo = tk.call("array", "get", "data" )
tclKeys = tk.call("dict", "keys", foo)
fromTcl = tk.call("dict", "get", foo, "first")
print(foo)
print(tclKeys)
print(fromTcl)
print(type(foo))
# print(dir(foo))
我知道我可以用tk.call("dict", "keys", foo)
得到键,然后用tk.call("dict", "get", foo, "...")
得到每个值,但是我想用一个tk.call
得到Python字典(参见desiredDict
)。这不是gui的问题,我不是在用gui工作。你知道吗
我不知道相关文档在哪里,但是如果您想使用Python和您介绍的方法,这确实有用:
Tkinter中没有用于检索Tcl dict的公共函数,但有一个私有函数:
相关问题 更多 >
编程相关推荐