python - 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'
解决方案
推荐阅读
- vue.js - Vue.js - 翻译文件以获得更好的性能
- java - 使用 SceneBuilder 的 JavaFX 错误
- java - Java 日期与收到的值相差一天
- python - DirectWrite 未针对变音符号进行调整
- javascript - 解析 JavaScript modal 的打开和关闭
- python - BOTO3 使用 Python 获取 EC2 列表的信息
- php - 如何导航 xml / xmlns 以提取 PHP 中的值和属性?
- c - 返回指向局部变量的指针是UB吗?
- gradle - Android 单元测试套件在个别测试通过时挂起
- git - 使用 git rev-list(或任何其他管道命令)访问 reflog 主题