为什么这段代码有效:
from PySide.QtCore import *
from PySide.QtGui import *
import sys
from functools import partial
import pyside # my code generated by QT Design
class MainDialog(QMainWindow, pyside.Ui_MainWindow):
def __init__(self, parent=None):
super(MainDialog,self).__init__(parent)
self.setupUi(self)
self.connect(self.Connect_buttom, SIGNAL("clicked()"), partial(self.get_fb_token, "aaaaa","bbbbbb"))
def get_fb_token(self,email,passwd):
print email
print passwd
app = QApplication(sys.argv)
form = MainDialog()
form.show()
app.exec_()
并打印aaaaa和bbbbb
但是如果我改变:
self.connect(self.Connect_buttom, SIGNAL("clicked()"), partial(self.get_fb_token, self.FB_username.text() ,self.FB_password.text()))
它不会打印我在文本框FB_password和FB_username中输入的内容(它不会崩溃,但它不会打印任何东西,就好像它没有将两个参数发送到函数get_fb_token
)???
** 参考自:http://www.blog.pythonlibrary.org/2013/04/10/pyside-connecting-multiple-widgets-to-the-same-slot/ 我正在使用QT和pyside
return something
。我可以这样做吗:something = self.Connect_buttom.clicked.connect(self.get_fb_token)
??? - Alberto