我嘗試在PyQt類中添加一個函數,但它總是返回一個錯誤。在PyQt中創建動態按鈕
# Error: TypeError: connect() slot argument should be a callable or a signal, not 'NoneType' #
def commander (self, arg):
exec arg
def aButton (self, layout, **kwargs):
name = kwargs.pop("name","Button")
command = kwargs.pop("command", "")
button = QtGui.QPushButton(name)
button.clicked.connect(self.commander(command))
layout.addWidget(button)
return button
可能是有人在這裏能幫助我解決了:') THX!
好'call' hehe .. –
謝謝!有用 ! – MObject
好吧!我是新來的;)thx再次:) – MObject