{: 'o 'clock textbooks' {' on the fifth grade: [' first unit', 'the second unit],
'under the fifth grade: [' first unit', 'the second unit],
'on the fourth grade: [' first unit', 'the second unit],
'under the fourth grade: [' first unit', 'the second unit]},
'new concept English: {' first book: [' first unit', 'the second unit],
'second volume: [' first unit', 'the second unit]}}
I think is similar to a tree in Pyqt5 directory in the form of display, it can fold and unfold every level of the sort of, which master know how to do? Thank you
CodePudding user response:
Has been solved, the code is as follows:Def showdir (self, dir) :
For I in dir:
# increase the root node
The self. The root=QTreeWidgetItem (self. TreeWidget)
The self. The root. The setText (0, I)
For j in dir [I] :
# increase level of child node
Self. Child1=QTreeWidgetItem (self. Root)
Self. Child1. SetText (0, j)
For k in dir [I] [j] :
# increase the secondary node
Self. Child2=QTreeWidgetItem (self. Child1)
Self. Child2. SetText (0, k)
The self. The treeWidget. The show ()