I\'m trying to make a basic XML story maker in PyQt. So far I\'ve been able to figure out everything my self, but I\'ve run into a bit of a snag. I can\'t figure out how to
You'll need to write something yourself to pull in the information from the XML file (hint: use a python XML parser like ElementTree). This code will build a tree widget with the rows (and subrows) filled out from data.
class Tree(QtGui.QTreeWidget):
def __init__(self, parent):
# maybe init your data here too
super(Tree, self).__init__(parent)
def populate(self, data):
# populate the tree with QTreeWidgetItem items
for row in data:
# is attached to the root (parent) widget
rowItem = QtGui.QTreeWidgetItem(parent)
rowItem.setText(0, row)
for subRow in row:
# is attached to the current row (rowItem) widget
subRowItem = QtGui.QTreeWidgetItem(rowItem)
subRowItem.setText(0, subRow)