From 9ca72f32ed04cb4fd60405a948dc2ade8a26c82d Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Fri, 11 Jan 2019 10:39:46 -0500 Subject: [PATCH] Tree Element - no longer puts an entry for the Root node (mimics tkinter) --- PySimpleGUIQt/PySimpleGUIQt.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/PySimpleGUIQt/PySimpleGUIQt.py b/PySimpleGUIQt/PySimpleGUIQt.py index 4c671411..67a74291 100644 --- a/PySimpleGUIQt/PySimpleGUIQt.py +++ b/PySimpleGUIQt/PySimpleGUIQt.py @@ -5393,19 +5393,22 @@ def PackFormIntoFrame(window, containing_frame, toplevel_win): # treeview.column(heading, width=width * CharWidthInPixels(), anchor=anchor) def add_treeview_data(node, widget): # print(f'Inserting {node.key} under parent {node.parent}') - child = QTreeWidgetItem(widget) - if node.key != '': + if node != element.TreeData.root_node: + child = QTreeWidgetItem(widget) child.setText(0, str(node.text)) - # child.setData(0,0,node.values) - if type(node.icon) is bytes: - ba = QtCore.QByteArray.fromBase64(node.icon) - pixmap = QtGui.QPixmap() - pixmap.loadFromData(ba) - qicon = QIcon(pixmap) - child.setIcon(0, qicon) - elif node.icon is not None: - qicon = QIcon(node.icon) - child.setIcon(0, qicon) + else: + child = widget + # if node.key != '': + # child.setData(0,0,node.values) + if type(node.icon) is bytes: + ba = QtCore.QByteArray.fromBase64(node.icon) + pixmap = QtGui.QPixmap() + pixmap.loadFromData(ba) + qicon = QIcon(pixmap) + child.setIcon(0, qicon) + elif node.icon is not None: + qicon = QIcon(node.icon) + child.setIcon(0, qicon) for node in node.children: add_treeview_data(node, child)