TypeError:connect()插槽参数应为可调用或信号,而不是“ NoneType”

时间:2018-07-02 23:41:59

标签: python pyqt4

我有一个表,显示从DB调用的行,每行都有一个打开另一个窗口的按钮,我需要使用函数将变量传递给其他窗口,这是怎么做的:

这就是我创建表并从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'

0 个答案:

没有答案