提问:
我把python文件包移动到了e盘,然后编辑器connect就报黄色了。
重装了python pyqt5 编辑器,现在编辑器没有黄色,但是:本机QT信号不可调用。
用之前写的代码运行不报错,现在写的就报错
代码:
import sys from PyQt5.QtWidgets import QWidget, QApplication, QPushButton class A(QWidget): def __init__(self): super(Ab, self).__init__() self.w() def w(self): self.resize(600, 600) self.b = QPushButton(self) self.b.clicked(self.xin) def xin(self): print("成功") def main(): app = QApplication(sys.argv) a = A() a.show() sys.exit(app.exec()) if __name__ == '__main__': main()
报错:
Traceback (most recent call last): File "E:\python文件2\信号.py", line 22, in <module> main() File "E:\python文件2\信号.py", line 18, in main a = A() ^^^ File "E:\python文件2\信号.py", line 9, in __init__ self.w() File "E:\python文件2\信号.py", line 13, in w self.b.clicked(self.xin) TypeError: native Qt signal is not callable
解答:
信号槽写的不对
self.b.clicked.connect(self.xin)
标签:__,clicked,python,self,PyQt5,报错,main From: https://www.cnblogs.com/dituirenwu/p/17092219.html