"Item . not found" 与 ttk.Treeview().insert()

"Item . not found" with ttk.Treeview().insert()

我正在尝试在具有五列的 tkinter 树视图中插入项目。我正在使用这行代码:

self.resultsTable.insert(parent=self.parent, index='end', values=['1','2','3','4','5'])

但是,解释器显示如下:

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

我在网上搜索了很多解决方案,但找不到。有没有对 tkinter 有经验的人可以帮助我?

我的猜测是您的 self.parent 代表根 window,它具有字符串表示形式“.”。该树告诉您它在树中没有任何 id 为 ".".

的项目

insert 的第一个参数 不是 小部件。它应该是空字符串——代表树中根项 的 ID——或先前插入的项的 ID。