首页 > 解决方案 > TypeError:connect() 插槽参数应该是可调用的或信号,而不是“NoneType”

问题描述

我有一个表格,显示从数据库调用的行,每一行都有一个打开另一个窗口的按钮,我需要使用该函数将一些变量传递给其他窗口,这是如何做到的:

那是我创建表并从 DB 中选择的地方:

number = 0
queue = 1
cur.execute("SELECT * FROM clinic WHERE Extra_Notice = 'x-ray is required'")
test_list = cur.fetchall()
for row in test_list:
    c_id = row[0]
    p_id = row[1]
    print p_id
    cur.execute("SELECT * FROM patient WHERE id = '%s'"%(p_id))
    pt = cur.fetchall()
    for pt_row in pt:
        pt_name = pt_row[1]
        pt_age = pt_row[2]
        pt_address = pt_row[4]
        pt_phone = pt_row[3]
    self.button = QtGui.QPushButton('Make Operation')
    self.button.setStyleSheet("background-color: #4f81bc; color: white;")
    self.button.clicked.connect(self.open_item_entry(p_id))
    rowPosition = self.tableWidget.rowCount()
    self.tableWidget.insertRow(rowPosition)
    self.tableWidget.setCellWidget(rowPosition , 0, self.button)
    self.tableWidget.setItem(rowPosition , 1, QtGui.QTableWidgetItem(str(pt_phone)))
    self.tableWidget.setItem(rowPosition , 2, QtGui.QTableWidgetItem(str(pt_address)))
    self.tableWidget.setItem(rowPosition , 3, QtGui.QTableWidgetItem(str(pt_age)))
    self.tableWidget.setItem(rowPosition , 4, QtGui.QTableWidgetItem(str(pt_name)))
    self.tableWidget.setItem(rowPosition , 5, QtGui.QTableWidgetItem(str(c_id)))
    self.tableWidget.setItem(rowPosition , 6, QtGui.QTableWidgetItem(str(queue)))
    queue += 1

我试图将按钮绑定到这一行中的函数self.button.clicked.connect(self.open_item_entry(p_id))

这是功能:

def open_item_entry(self, pt_name):
    self.window = QtGui.QDialog()
    self.ui = Ui_Report1()
    self.ui.setupUi(self.window)
    self.window.show()

当我尝试单击按钮时出现此错误:

TypeError: connect() slot argument should be a callable or a signal, not 'NoneType'

标签: pythonpyqt4

解决方案


推荐阅读