PyQt5中TextBrowser显示print语句输出

目的:将程序的输出内容在TextBrowser中显示
实现:
假定定义的TextBrowser名为textBrowser,主界面名为Ui_MainWindow。直接定义一个textBrowser的输出函数:

def printf(self, mes):
        self.textBrowser.append(mes)  # 在指定的区域显示提示信息
        self.cursot = self.textBrowser.textCursor()
        self.textBrowser.moveCursor(self.cursot.End)

想要在TextBrowse中显示输出时,直接调用printf即可:

Ui_MainWindow.printf(self, "程序输出内容")
发布了6 篇原创文章 · 获赞 4 · 访问量 90

猜你喜欢

转载自blog.csdn.net/Fighting_y/article/details/104898982
今日推荐