# Error: PySide2.QtCore.QObject.connect(): not enough arguments
# Traceback (most recent call last):
# File "<maya console>", line 5, in <module>
# File "E:\ProfessionalDevelopment\python\Introduction to Python Scripting in Maya\cgcircuitPython\wk6\wk6_homeWorkUI.py", line 26, in run
# win = GeometryGenerator(parent=getMayaWindow())
# File "E:\ProfessionalDevelopment\python\Introduction to Python Scripting in Maya\cgcircuitPython\wk6\wk6_homeWorkUI.py", line 70, in __init__
# self.makeConnections()
# File "E:\ProfessionalDevelopment\python\Introduction to Python Scripting in Maya\cgcircuitPython\wk6\wk6_homeWorkUI.py", line 82, in makeConnections
# self.Pbtn_randomlyDistribute.connect(self.randomlyPlaceA)
# TypeError: PySide2.QtCore.QObject.connect(): not enough arguments #
Here is the Code.
# Loading a Qt Designer UI file and editing the loaded widget
import os
import functools
from PySide2 import QtWidgets, QtCore, QtUiTools, QtGui
from shiboken2 import wrapInstance
import maya.cmds as mc
import maya.OpenMayaUI as omui
import makeRobotBug, makeSpiralStairs, randomlyPlace
'''
import thisModule
reload (thisModule)
thisModule.run()
'''
def getMayaWindow():
''' pointer to the maya main window '''
ptr = omui.MQtUtil.mainWindow()
if ptr:
return wrapInstance(long(ptr), QtWidgets.QMainWindow)
def run():
''' builds our UI '''
global win
win = GeometryGenerator(parent=getMayaWindow())
#win.show()
class GeometryGenerator(QtWidgets.QDialog):
def __init__(self,parent=None):
super(GeometryGenerator,self).__init__(parent)
#self.resize(400, 300)
## From Pysideuic compiled code goes here
#############################################################
self.gridLayout = QtWidgets.QGridLayout()
self.verticalLayout = QtWidgets.QVBoxLayout()
self.verticalLayout.setContentsMargins(5, 5, 5, 5)
self.verticalLayout_3 = QtWidgets.QVBoxLayout()
self.verticalLayout_3.setContentsMargins(5, 5, 5, 5)
self.Pbtn_makeRobot = QtWidgets.QPushButton("MAKE ROBOT")
self.verticalLayout_3.addWidget(self.Pbtn_makeRobot)
self.verticalLayout.addLayout(self.verticalLayout_3)
self.verticalLayout_4 = QtWidgets.QVBoxLayout()
self.verticalLayout_4.setContentsMargins(5, 5, 5, 5)
self.Pbtn_makeStairs = QtWidgets.QPushButton("MAKE STAIRS")
self.verticalLayout_4.addWidget(self.Pbtn_makeStairs)
self.verticalLayout.addLayout(self.verticalLayout_4)
self.verticalLayout_2 = QtWidgets.QVBoxLayout()
self.verticalLayout_2.setContentsMargins(5, 5, 5, 5)
self.Pbtn_randomlyDistribute = QtWidgets.QPushButton("Randomly Place Robot and Spiral Staircase")
self.verticalLayout_2.addWidget(self.Pbtn_randomlyDistribute)
self.verticalLayout.addLayout(self.verticalLayout_2)
self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1)
##############################################################
self.setWindowTitle("WIN CONTROLLED IN PYTHON")
self.setLayout(self.gridLayout)
self.show()
self.makeConnections()
self.initialUiState()
def initialUiState(self):
self.Pbtn_makeRobot.toggle()
self.Pbtn_makeStairs.toggle()
self.Pbtn_randomlyDistribute.toggle()
def makeConnections(self):
''' connect events in out UI '''
self.Pbtn_makeRobot.clicked.connect( self.makeRobotBug )
self.Pbtn_makeStairs.clicked.connect(self.makeSpiralStairs)
self.Pbtn_randomlyDistribute.connect(self.randomlyPlaceA)
def makeRobotBug(self):
makeRobotBug.makeRobotBug()
def makeSpiralStairs(self):
makeSpiralStairs.makeSpiralStairs()
def randomlyPlaceA(self):
randomlyPlace.randomlyPlace()
The way you can spot it, is by (1) looking at the error message..
# TypeError: PySide2.QtCore.QObject.connect(): not enough arguments #
..followed by (2) going to the docs for that object and method..
And you’ll find that indeed, it takes more than a single argument, and the first argument is of type QObject.
--
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+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/711d1f24-94ce-472a-adb7-1e1944db51e9%40googlegroups.com.