Jump to content
mohamaedkamal

error with qt

Recommended Posts

I have some error when I extract some data from dops to adding this data in qlist using python qt

 def print_seltected (self):

        node = hou.selectedNodes()

        node.name()

 

"AttributeError: 'tuple' object has no attribute 'name'"

Edited by mohamaedkamal

Share this post


Link to post
Share on other sites

Not a PySide2, just an ordinary HOM error. Try "hou.selectedNodes()[0]".

hou.selectedNodes() returns tuple containing node objects: (node0, node1, ...). If you need first element from it (node0), use hou.selectedNodes()[0]. If one node is selected, it will be tuple of one element: (node0, ), so, you still need to access it like a tuple. If nothing is selected, empty tuple will be returned (,) and accessing it's first element will raise an error. You may want to add a check for it's content, for example "if hou.selectedNodes():" block will work.

  • Like 1

Share this post


Link to post
Share on other sites

hou.selectedNodes() returns a tuple of nodes not a single node.

for n in hou.selectedNodes():
	print n.name()

 

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×