"""
windows文件
"""
from PySide2 import QtWidgets
import pymel.core as pm
import mvc_model
import msv
import maya_helpers
reload(msv)
reload(mvc_model)
class ShowWindow(QtWidgets.QMainWindow, msv.Ui_MainWindow):
def __init__(self, data_all):
self.maya_mainwindow = maya_helpers.maya_mainwindow()
super(ShowWindow, self).__init__(self.maya_mainwindow)
self.data = data_all
self.setupUi(self)
self.setupUi2()
self.singal_connect()
def setupUi2(self):
self.list_model1 = mvc_model.ListModel(self.data[0], self.listView_1)
self.list_model2 = mvc_model.ListModel(self.data[1], self.listView_2)
self.list_model3 = mvc_model.ListModel(self.data[2], self.listView_3)
self.listView_1.setModel(self.list_model1)
self.listView_2.setModel(self.list_model2)
self.listView_3.setModel(self.list_model3)
def singal_connect(self):
self.listView_1.clicked.connect(self.select_obj1)
self.listView_2.clicked.connect(self.select_obj2)
self.listView_3.clicked.connect(self.select_obj3)
def select_obj1(self, qModelIndex):
obj_name = self.data[0][qModelIndex.row()]
pm.select(obj_name)
def select_obj2(self, qModelIndex):
obj_name = self.data[1][qModelIndex.row()]
pm.select(obj_name)
def select_obj3(self, qModelIndex):
obj_name = self.data[2][qModelIndex.row()]
pm.select(obj_name)
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
foo = ShowWindow()
foo.show()
sys.exit(app.exec_())
"""
listModel 文件
"""
from PySide2 import QtCore
from PySide2 import QtGui
class ListModel(QtCore.QAbstractListModel):
def __init__(self, list_data, parent=None):
super(ListModel, self).__init__(parent)
self.list_data = list(list_data)
def rowCount(self, parent=QtCore.QModelIndex()):
return len(self.list_data)
def data(self, index=QtCore.QModelIndex(), role=QtCore.Qt.DisplayRole):
if role == QtCore.Qt.DisplayRole or role == QtCore.Qt.EditRole:
content = self.list_data[index.row()]
return content
if role == QtCore.Qt.ForegroundRole:
return QtGui.QColor(255, 0, 0)
def flags(self, index=QtCore.QModelIndex()):
return QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEditable
def setData(self, index=QtCore.QModelIndex(), value=None, role=QtCore.Qt.EditRole):
if value != None:
self.list_data[index.row()] = value
self.dataChanged.emit(index, index)
return True