qq_43412960
2019-12-04 15:06
采纳率: 50%
浏览 275
已采纳

这是一个关于PYTHON 的PYQT5问题

import sys,time
import  threading
from PyQt5 import QtWidgets,QtCore,QtGui
import zuoye2,datetime
import   socket
class Mywindow(QtWidgets.QMainWindow, zuoye2.Ui_MainWindow):
    def __init__(self):

        super(Mywindow,self).__init__()

        self.setupUi(self)  #继承于Ui_MainWindow
        self.pushButton.clicked.connect(self.zuoya)
        self.pushButton_2.clicked.connect(self.youya)
        self.pushButton_3.clicked.connect(self.clo)
    def  clo(self):
         self.close()

    def you(self,A):


            self.textEdit_2.append(A)

    def zuoya(self):
        thread = mythread()
        thread.signal.connect(self.zuo)
        thread.start()


    def zuo(self,A):
        self.textEdit.append(A)
    def youya(self):
        pass
    #     thread = mythread()
    #     thread.signal.connect(self.you)
    #     thread.start()
#       self.quest = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#         self.pushButton_3.clicked.connect(self.lianjie)
#         self.pushButton.clicked.connect(self.xiaoxi)
#         self.pushButton_2.clicked.connect(self.guanbi)
#     def  lianjie(self):
#         self.port = int(self.lineEdit_2.text())
#         a=(self.lineEdit.text(),self.port)
#         self.quest.connect((self.lineEdit.text(),self.port))
#         self.pushButton_3.setEnabled(False)
#         # print(self.lineEdit.text())
#     def  getfun(self,str):
#         self.textEdit.setText(str)
#     def  xiaoxi(self):
#
#             self.quest.send('hellow'.encode())
#             data=self.quest.recv(100).decode()
#             self.textEdit.append(data)
#     def  guanbi(self):
#         self.quest.close()
#         QtCore.Application.instance().quit
#
# class   mythread(QtCore.QThread):
#     singal=QtCore.pyqtSignal(str)
#     def  __init__(self,soc):
#       QtCore. [QThread.__init__(self)
#       self.soc=soc

#
class mythread(QtCore.QThread):
       signal = QtCore.pyqtSignal(str)

       def  run(self):
          # for i in range(1,10,1):

            self.signal.emit(str(datetime.datetime.now()))




if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    window = Mywindow()
    window.show()


    sys.exit(app.exec_())

上面是我写的窗体连接代码 。 窗体 代码没写,但是 看名字应该可以看出来是什么部件的 对吧 。
有个很奇怪的问题 ,我单步调试的时候,程序就没有问题
如果直接运行程序吗,图片说明

就产生了这个错误,这是为什么呢?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题