[英]“Item . not found” with ttk.Treeview().insert()
I'm trying to insert items in a tkinter treeview with five columns. 我正在尝试在具有五列的tkinter树视图中插入项目。 I'm using this line of code:
我正在使用以下代码行:
self.resultsTable.insert(parent=self.parent, index='end', values=['1','2','3','4','5'])
However, the interpreter shows the following: 但是,解释器显示以下内容:
Exception in thread Thread-3:
Traceback (most recent call last):
File "C:\Python34\lib\threading.py", line 920, in _bootstrap_inner
self.run()
File "C:\Python34\lib\threading.py", line 868, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\gigi\Desktop\me\projects\PyMusic\test\threaded_test.py", line 166, in searchMusic
self.showResults()
File "C:\Users\gigi\Desktop\me\projects\PyMusic\test\threaded_test.py", line 111, in showResults
self.resultsTable.insert(parent=self.parent, index='end', values=['1','2','3','4','5']) # values=song['details']
File "C:\Python34\lib\tkinter\ttk.py", line 1337, in insert
res = self.tk.call(self._w, "insert", parent, index, *opts)
_tkinter.TclError: Item . not found
I searched a lot on the web for a solution, but I couldn't find one. 我在网上搜索了很多解决方案,但找不到。 Is there anyone experienced with tkinter who can help me?
有tkinter经验丰富的人可以帮助我吗?
My guess is that your self.parent
represents the root window, which has a string representation of ".". 我的猜测是您的
self.parent
表示根窗口,其字符串表示形式为“。”。 The tree is telling you that it doesn't have any items in the tree with an id of "."
该树告诉您树中没有ID为
"."
任何项目"."
. 。
The first argument to insert
is not a widget. 要
insert
的第一个参数不是小部件。 It should be either the empty string -- which represents the id of the root item in the tree -- or the id of a previously inserted item. 它应该是空字符串(表示树中根项目的ID)或先前插入的项目的ID。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.