这是报错:
这是调试代码:
import sys
from PyQt6 import QtWidgets
from PyQt6.QtCore import QThread
from PyQt6.QtCore import pyqtSignal
import PD # PyUic生成的UI文件
class Windows(QtWidgets.QMainWindow, PD.Ui_MainWindow):
def __init__(self):
super(Windows, self).__init__()
self.setupUi(self)
self.add_text = AddText()
self.add_text.start()
self.add_text.signal.connect(self.add_box)
def add_box(self, text):
pass
class AddText(QThread):
signal = pyqtSignal(list)
def __init__(self):
"""子线程,用于调试文本"""
super(AddText, self).__init__()
self.txt = list()
def run(self):
while True:
self.input_txt()
self.signal.emit(self.txt)
def input_txt(self):
try:
val = input("请输入:")
self.txt.append(val)
except Exception as e:
pass
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Windows()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec())
tips:
Fatal Python error: _enter_buffered_busy: could not acquire lock for <_io.BufferedReader name='<stdin>'> at interpreter shutdown, possibly due to daemon threads
Python runtime state: finalizing (tstate=00000281F05B0960)
Current thread 0x000034ac (most recent call first):
<no Python frame>