likage
2018-09-07 23:56:57 UTC
Hi all,
I have a list of node's full dag path as follows:
|Base|character|Mike|body
|Base|character|John
|Base|camera
I am trying to populate them in a Tree View hierarchy using PyQt based on
the above queried paths so that the tree view will be something as follow:
|-- Base
|--|-- character
|--|--|-- Mike
|--|--|--|-- body
|--|--|-- John
|--|-- camera
but instead in my UI, I got:
|Base
|Base|character
|Base|character|Mike
|Base|character|Mike|body
|Base
|Base|character
|Base|character|John
|Base
|Base|camera
where some of the hierarchy are created twice and they are populated as a
value in each row instead of the 'small arrow' sign where you can expand
them to view the next hierarchy.
This is my code:
class MyModel(QtGui.QStandardItemModel):
def __init__(self, parent=None):
super(MyModel, self).__init__(parent)
self.get_contents()
def get_contents(self):
self.clear()
#contents=
predicate_helpers.get_expanded_objects_of_behaviour("rig")
contents = [
'|Base|character|Mike|body',
'|Base|character|John',
'|Base|camera'
]
for content in contents:
count = content.count('|')
for index in range(count):
index = index + 2
split_path = '|'.join(content.split('|')[0:index])
self.add_item(split_path)
def add_item(self,name):
item1 = QtGui.QStandardItem(name)
self.appendRow([item1])
Can anyone kindly provide me any insights?
I have a list of node's full dag path as follows:
|Base|character|Mike|body
|Base|character|John
|Base|camera
I am trying to populate them in a Tree View hierarchy using PyQt based on
the above queried paths so that the tree view will be something as follow:
|-- Base
|--|-- character
|--|--|-- Mike
|--|--|--|-- body
|--|--|-- John
|--|-- camera
but instead in my UI, I got:
|Base
|Base|character
|Base|character|Mike
|Base|character|Mike|body
|Base
|Base|character
|Base|character|John
|Base
|Base|camera
where some of the hierarchy are created twice and they are populated as a
value in each row instead of the 'small arrow' sign where you can expand
them to view the next hierarchy.
This is my code:
class MyModel(QtGui.QStandardItemModel):
def __init__(self, parent=None):
super(MyModel, self).__init__(parent)
self.get_contents()
def get_contents(self):
self.clear()
#contents=
predicate_helpers.get_expanded_objects_of_behaviour("rig")
contents = [
'|Base|character|Mike|body',
'|Base|character|John',
'|Base|camera'
]
for content in contents:
count = content.count('|')
for index in range(count):
index = index + 2
split_path = '|'.join(content.split('|')[0:index])
self.add_item(split_path)
def add_item(self,name):
item1 = QtGui.QStandardItem(name)
self.appendRow([item1])
Can anyone kindly provide me any insights?
--
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_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/36fbcfda-0e55-4901-af8a-baff7585ffbf%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_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/36fbcfda-0e55-4901-af8a-baff7585ffbf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.