tree = {'users': { "John" : ["graphics"], "Alice": ["book", "people"] }}
class MainWindow(QtGui.QMainWindow): def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.tree_view = QtGui.QTreeView() self.setCentralWidget(self.tree_view) self.set_selection()
self.model = QtGui.QStandardItemModel() self.populateTree(tree, self.model.invisibleRootItem()) self.tree_view.setModel(self.model) self.tree_view.expandAll()
def populateTree(self, children, parent): for child in children: child_item = QtGui.QStandardItem(child) parent.appendRow(child_item) if isinstance(children, dict): self.populateTree(children[child], child_item)
def set_selection(self): to_set = "/user/Alice/people" view = self.tree_view.selectionModel() index = self.model.indexFromItem(to_set) view.select(QItemSelectionModel.Select|QItemSelectionModel.Rows)
win = MainWindow()win.show()
for row in range(self.tree_view.rowCount()): data.append([])for column in range(self.tree_view.columnCount()): index = self.tree_view.index(row, column) data[row].append(str(self.tree_view.data(index).toString()))
# TypeError: rowCount() takes exactly 2 arguments (1 given) #
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/2c10335c-874c-494d-820f-7142980d725a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/5d51a6af-23da-4c71-9946-bc641dfd0cdb%40googlegroups.com.
for part in (parts):
...
Hi Justin,Many thanks for getting back to me on this.I do have some questions (kindly pardon my questions).1. Why is there a need to use `enumerate`? It seems that the variable - `i` is not being used anywhere.. If so, wouldn't it be better to use/ write it as
for part in (parts):
...
2. I am still not quite understanding the usage of `PATH_ROLE` or `self.PATH_ROLE`? Especially the latter not being declared anywhere before it has been used?
3. Lastly, about the `itemFromPath()`, what is the argument - `parent`?
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/646bd0ca-9316-4e09-9b21-28e593231578%40googlegroups.com.