Ok, Here's and basic example with PyQT and a QListWidget...
Please note. This use's a modified pumpThread module. The default one from the maya dev kit has given us lots of problems.
Thanks to some very clever people on this list we now have a working pumpThread module that is heavily tested here at work.
from PyQt4 import QtCore, QtGui
import pymel as pm
import pumpThread
class ExampleUI(QtGui.QDialog):
def __init__(self, parent=None):
super(ExampleUI, self).__init__(parent)
# Set some basic properties on the UI
self.setWindowTitle('ExampleUI')
self.setObjectName("ExampleUI")
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
# Add a Layout and set it to the UI
self.mainLayout = QtGui.QVBoxLayout(self)
self.setLayout(self.mainLayout)
# Add a Button and set some properties. Also add it to a layout.
self.RefreshButton = QtGui.QPushButton()
self.RefreshButton.setText("Refresh")
self.mainLayout.addWidget(self.RefreshButton)
# Add a list and set it to the layout
self.SelectionList = QtGui.QListWidget()
self.SelectionList.setMinimumSize(250,250)
self.mainLayout.addWidget(self.SelectionList)
# Connect the Refresh Button to a function to populate the list using SIGNAL's
self.connect(self.RefreshButton, QtCore.SIGNAL("clicked()"), self._RefreshButtonFunc)
def _RefreshButtonFunc(self):
'''
Fill the list based on a maya selection
'''
oSel = pm.selected()
if oSel:
self.SelectionList.clear()
[self.SelectionList.addItem(
s.name()) for s in oSel]
else:
self.SelectionList.clear()
@staticmethod
def Display():
'''
calls the window. Typical PumpThread call
Use's a modified pumpThread that properly set's up the thread.
'''
# We need a global to stop python gc the UI
global mainWindow
# We need pumpThread to make the UI responsive
pumpThread.initializePumpThread()
app = pumpThread.get_app()
if app:
# We can set the app to use a nice style
app.setStyle('Plastique')
mainWindow = ExampleUI()
mainWindow.show()
ExampleUI.Display()
I'll post our final pumpThread later today.
-Dave