Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 是否只允许一个具有Treeview值的单词?_Python_Tkinter_Widget_Treeview_Tk - Fatal编程技术网

Python 是否只允许一个具有Treeview值的单词?

Python 是否只允许一个具有Treeview值的单词?,python,tkinter,widget,treeview,tk,Python,Tkinter,Widget,Treeview,Tk,我可能在这里遗漏了一些非常明显的东西,因为我对Treeview完全陌生,但是当我插入我的值(在本例中为“Hello there”)时,只有“Hello”输出-总是只有出现的第一个单词 正如你可能看到的,我试图制作一个带有固定值的利弊表,但我认为你必须有一个“#0”列,所以我把这个列作为我的“优点”列——这是做事情的最佳方式吗 symmetric_tree=ttk.Treeview(symmetric_tab) symmetric_tree["columns"]=("

我可能在这里遗漏了一些非常明显的东西,因为我对Treeview完全陌生,但是当我插入我的值(在本例中为“Hello there”)时,只有“Hello”输出-总是只有出现的第一个单词

正如你可能看到的,我试图制作一个带有固定值的利弊表,但我认为你必须有一个“#0”列,所以我把这个列作为我的“优点”列——这是做事情的最佳方式吗

symmetric_tree=ttk.Treeview(symmetric_tab)

symmetric_tree["columns"]=("one")
symmetric_tree.column("#0", width=270, minwidth=270)
symmetric_tree.column("one", width=150, minwidth=150)

symmetric_tree.heading("#0",text="Pros",anchor=W)
symmetric_tree.heading("one", text="Cons",anchor=E)

symmetric_tree.insert(parent="", index="end", iid="#0", text="Easy to implement", 
                      values=("Hello there"))

symmetric_tree.pack(side="top",fill="x")

treeview方法要求您传递值的列表或元组。您正在传递一个值。由于它不是一个列表,内部tcl解释器通过在空格上拆分将该值转换为一个列表

解决方案是将列表或元组传递给
insert
。请注意,
(“Hello there”)
是一个值,
(“Hello there”)
是一个具有单个值的元组

symmetric_tree.insert(..., values=("Hello there",))
        

tcl在空间上拆分不是很奇怪吗?我想如果它是python,它会遍历字符串“Hello World”并生成11个条目?@CoolCloud tkinter只是将它提供的内容传递给底层的tcl解释器。在Tcl解释器中拆分空格是该语言的基础。