Here you go. Had to make some changes to your code to make it work.
You had set your central layout to the treeview layout. You actually need 
to set it to the layout that contains everything you need.


-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/c3fabb0a-6b8c-4037-b428-f8f89a3ad2c7%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
from PyQt4 import QtCore, QtGui
import cPickle

import maya.OpenMayaUI
import maya.OpenMaya as api
import maya.cmds as cmds
import testtree


import sip

def mayaMainWindow():
    '''Returns the Maya window as a QMainWindow instance.'''
    ptr = maya.OpenMayaUI.MQtUtil.mainWindow()
    if ptr is not None:
        return sip.wrapinstance( long(ptr), QtCore.QObject )


class Selector( QtGui.QMainWindow ):


    def __init__( self, parent=mayaMainWindow() ):

        super( Selector, self ).__init__( parent )

        self.setWindowTitle("SelectionUI")
        self.resize(250,600)


        self.setObjectName('SelectorUI')

        sel=cmds.ls(sl=True)
        if not sel:
            raise UserWarning("User needs to select an object with children")

        sel=sel[0]
        nodes=[]
        nodes = cmds.listRelatives(sel, allDescendents=True)
        nodes.append(sel)
        nodes.reverse()
        rootNode = testtree.getNodeType(nodes[0])
        childNode0 = testtree.getNodeType(nodes[1],         rootNode)
        childNode1 = testtree.getNodeType(nodes[2],         childNode0)
        childNode2 = testtree.getNodeType(nodes[3],         childNode1)
        childNode3 = testtree.getNodeType(nodes[4],         childNode2)
        lightNode1 = testtree.getNodeType('pointLight1',     rootNode)


        model=testtree.SceneGraphModel(rootNode)

        widget = QtGui.QWidget()
        self.layout = QtGui.QVBoxLayout(widget)


        treeview_widget=QtGui.QWidget()

        treeview_layout=QtGui.QHBoxLayout(treeview_widget)
        treeview_layout.setContentsMargins(10,10,10,10)

        self.tree=QtGui.QTreeView()
        self.tree.setModel(model)
        self.tree.setAlternatingRowColors(True)
        self.tree.setMaximumHeight(300)

        treeview_layout.addWidget(self.tree)

        label=QtGui.QLabel("SelectionUI")
        self.layout.addWidget(label)

        button_widget = QtGui.QWidget()
        button_layout = QtGui.QHBoxLayout(button_widget)
        self.refresh_button = QtGui.QPushButton("Refresh")
        self.cancel_button = QtGui.QPushButton("Cancel")
        button_layout.addWidget(self.refresh_button)
        button_layout.addWidget(self.cancel_button)

        self.layout.addWidget(treeview_widget)
        self.layout.addWidget(button_widget)
        self.setCentralWidget( widget )

        self.show()

Reply via email to