2

Im building a GUI and I'm using the Treeview widget of tkinter. My problem is i do not know how to hide rows. I also didn't find any variabel to set to do that.

The only possibility im thinking of is creating a 2nd tree, which is not displayed which contains all the items and only the choosen ones are getting "copied" to the tree which gets displayed. But I do not think that this is the best solution of that problem.

Pls help me guys, thanks in advance

Mossi
  • 81
  • 9
  • 2
    There are [`detach`](https://docs.python.org/3/library/tkinter.ttk.html#tkinter.ttk.Treeview.detach) and [`reattach`](https://docs.python.org/3/library/tkinter.ttk.html#tkinter.ttk.Treeview.reattach) methods for this purpose. See [this](https://stackoverflow.com/questions/44565358/how-to-filter-a-ttk-treeview-in-python) post for a sample. – Henry Yik Mar 03 '20 at 07:33

1 Answers1

5

Thank you, Henry Yik, for your help. Here is just a short example if somebody has the same problem

  def hide(self):
    d=self.tree.get_children()
    self.tree.detach(d[0])
    self.detached_items.append(d[0])

  def unhide(self):       
    for i in self.detached_items:
        self.tree.reattach(i,'',0)
    self.detached_items.clear()

detached_items is a list createad at the treeview creation

tree is the treeview widget

Mossi
  • 81
  • 9