Hi Guys, I am tring to create one window with pyside2. I have never worked with pyside before. I have already created the basic window from QtDesigner. What i want is, i want to create as many buttons as there is an icon available in specific folder. Below code is creating the button as many icons there but its not giving name and i can give only one button pressed command, every button will work exactly same. I have uploaded the image of ui created in maya running below code.
Can anybody help me with this? Thanks in advance. This is the code from QtDesigner:- fileName (createModuleUI.py) from PySide2 import QtCore, QtGui, QtWidgets class Ui_Form(object): def setupUi(self, Form): Form.setObjectName("Form") Form.resize(299, 457) self.verticalLayout = QtWidgets.QVBoxLayout(Form) self.verticalLayout.setObjectName("verticalLayout") self.searchLine = QtWidgets.QLineEdit(Form) self.searchLine.setText("") self.searchLine.setObjectName("searchLine") self.verticalLayout.addWidget(self.searchLine) self.scrollArea = QtWidgets.QScrollArea(Form) self.scrollArea.setWidgetResizable(True) self.scrollArea.setObjectName("scrollArea") self.scrollAreaWidgetContents = QtWidgets.QWidget() self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 273, 366)) self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents) self.verticalLayout_2.setObjectName("verticalLayout_2") self.scrollArea.setWidget(self.scrollAreaWidgetContents) self.verticalLayout.addWidget(self.scrollArea) self.createModuleButton = QtWidgets.QPushButton(Form) self.createModuleButton.setObjectName("createModuleButton") self.verticalLayout.addWidget(self.createModuleButton) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form) def retranslateUi(self, Form): Form.setWindowTitle(QtWidgets.QApplication.translate("Form", "Create Module", None, -1)) self.createModuleButton.setText(QtWidgets.QApplication.translate("Form", "Create Module", None, -1)) This is the part of code where i am looking for icons and creating buttons. class createModule(createModuleUI.Ui_Form, QtWidgets.QDialog): def __init__(self, parentWin=getMayaWindow()): super(createModule, self).__init__(parentWin) self.setupUi(self) self.setProperty("saveWindowPref", True) self.populateCreateModuleButtons() def populateCreateModuleButtons(self): iconPath = cmds.internalVar(usd=True).rsplit("/", 3)[0] + "/scripts/spDev/rigging/sp_modularRig/sp_UI/icons" icons = [] # to removeWarning. try: icons = sorted(listdir(iconPath)) except: cmds.error("Icons path not found.") for icon in icons: objectName = icon.split("__")[1].split(".")[0] + " Module Button" self.ModuleButton = QtWidgets.QPushButton() self.ModuleButton.setObjectName(objectName) self.verticalLayout_2.addWidget(self.ModuleButton) spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.verticalLayout_2.addItem(spacerItem) Icon naming is [biped__Hand.png, biped__Leg.png, biped__Torso.png] currently only 3 is there. -- 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_maya+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/fd805401-dfeb-46dc-a4ce-5f119dd95d8d%40googlegroups.com.