#mayas selection vioa pymel
maya_list = pm.selected()
#connection from button to refresh list
button.clicked.connect(refresh)
#the refresh function adds the maya_list
refresh(self):
self.listWidget.clear()
self.listWidget.addItem(maya_list)
you have to loop through and add an item at a time like this:
from PySide import QtGui, QtCore
#clear it out
def refresh(self):
self.listWidget.clear()
items = pm.selected()
for item in items:
newItem = QtGui.QListWidgetItem( item.nodeName())
self.listWidget.addItem(newItem)
try that
--
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/d2e2cff9-3157-428c-bc11-05b17b7a0aa2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
And for your next step in dealing with your line edit, you may want to think about switching to a QListView + QStandardItemModel + Qsortfilterproxymodel. That would easily let you apply filter strings/patterns on your model. Otherwise you might have to loop over the items in your QListWidget and manually test the text value of each one, and set the hidden state. I don't remember if a QListWidget let's you put a Qsortfilterproxymodel in between it. Maybe it does.
Justin
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CABPXW4i%3D7QfwY5iX86trtxVOQceNySyU0fKxQXieYTPWRnfKjg%40mail.gmail.com.
Padraig
Hi Geordie and Justin, I tried your function and for some reason I am nt getting any output at all on selecting objects and pushbutton. I'll give more details later on when I get time thank you.
Padraig
--
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/250d829a-89d4-4c10-8540-4dcb18957793%40googlegroups.com.
import PySide
from PySide import QtGui, QtCore
from maya import OpenMayaUI as omui
from shiboken import wrapInstance
import pymel.core as pm
from PysideCode.scroller.uiCode import scrollerUI
from PySide.QtGui import QWidget, QMainWindow
pointer = omui.MQtUtil.mainWindow()
mayaMainWindow = wrapInstance(long(pointer), QWidget)
class mainWindow(QMainWindow, scrollerUI.Ui_MainWindow ):
def __init__(self, parent=mayaMainWindow):
super(mainWindow, self).__init__(parent)
self.setupUi(self)
self.pushButton.clicked.connect(self.reList)
def reList(self):
self.listWidget.clear()
items = pm.selected()
for item in items:
newItem = PySide.QtGui.QListWidgetItem(item.nodeName())
self.listWidget.addItem(newItem)
if __name__ == '__main__':
try:
mainWindow.close()
except:
pass
win = mainWindow()
win.show()
--
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/da81e63d-1834-4b1b-9c8d-a0ddd097c1b5%40googlegroups.com.
By capping out I mean that after day 5 or more execute of the script I get a winEvent error and have to force close maya.
Its not too much different if you use QStandardItemModel. The difference is that you just add items to the model instead of the view. It still has that high level item approach.
bah its kind of hard to impliment the qListView
--
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/1f49d799-f178-4b90-bfa0-e8282895fb89%40googlegroups.com.
import pymel.core as pm
from maya import OpenMayaUI as omui
import shibokenfrom PysideCode.scroller.uiCode import scrollerUI
from PySide import QtGui, QtCore
from PySide.QtGui import QWidget
pointer = omui.MQtUtil.mainWindow()mayaMainWindow = shiboken.wrapInstance(long(pointer), QWidget)
class mainWindow(PySide.QtGui.QMainWindow, scrollerUI.Ui_MainWindow):
def __init__(self, parent=mayaMainWindow): super(mainWindow, self).__init__(parent) self.setupUi(self)
#connections self.pushButton.clicked.connect(self.reList) self.listView.clicked.connect(self.selectionHandler) self.lineEdit.textChanged.connect(self.filterHandler) self.statusbar.showMessage('You selected it')
def reList(self): for node in pm.selected(): self.model.clear() item = QtGui.QStandardItem() item.setText(str(node)) self.model.appendRow(item)
def selectionHandler(self, index): index = self.proxy.mapToSource(index) item = self.model.itemFromIndex(index)
pm.select(item.data())
def filterHandler(self): regex = '.*{}.*'.format(self.lineEdit.text().replace(' ', '.*')) self.proxy.setFilterRegExp(regex) self.proxy.invalidateFilter()
if __name__ == "__main__":
global win try: win.close() win.deleteLater()
except: pass win = mainWindow() win.show()
--
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/79edac09-c420-4c51-8505-ed660d885c04%40googlegroups.com.
Ah yeah I figured that out afterwards haha. Same stupid mistake. Now that the search function and the new model is done. It's time to move onto the status bar. For more complex work with selections like what rob has in his book.
Padraig