ui转py文件
在已安装pyqt5的情况下,cmd,输入d:,进入d盘,然后cd 路径,进入路径环境,输入:
pyuic5 your_ui_file.ui -o output_file.py
PyQt5 QTextEdit
textEdit为窗口名称
self.textEdit.setText('检测串口中') self.textEdit.append('串口已开启') self.textEdit.setPlainText('1\n2')
注意:使用 time.sleep()
函数来暂停程序的执行,这会导致整个操作在短时间内被阻塞,而界面无法及时更新。具体来说,在 setText
和 append
后面的 time.sleep
期间,界面不会刷新,直到整个函数执行完毕。
例如
def shishi2(self): self.textEdit.setText('检测串口中') time.sleep(2) self.textEdit.setText('串口已开启') time.sleep(1) self.textEdit.append('开始读取数据') time.sleep(1)