解决PyQt: RuntimeError: wrapped C/C++ object has been deleted和has no attribute of flush in python
上篇文章的将命令行输出重定向到UI界面之后,在关闭UI界面时候会报错has no attribute of flush in python或者PyQt: RuntimeError: wrapped C/C++ object has been deleted解决方案是在命令行输出重定向到的类里面添加一个函数:class ButtonOne(QThread):_signalForText = pyqt
·
上篇文章的将命令行输出重定向到UI界面之后,在关闭UI界面时候会报错
has no attribute of flush in python或者
PyQt: RuntimeError: wrapped C/C++ object has been deleted
解决方案是在命令行输出重定向到的类里面添加一个函数:
class ButtonOne(QThread):
_signalForText = pyqtSignal(str)
def __init__(self):
super(ButtonOne, self).__init__()
def write(self, text):
self.signalForText.emit(text)
def run(self):
for i in range(15):
time.sleep(1)
print(i)
print('end')
@property
def signalForText(self):
return self._signalForText
def flush(self):
pass
这样就可以解决。
添加的函数为:
def flush(self):
pass
更多推荐
已为社区贡献1条内容
所有评论(0)