目的:将程序的输出内容在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, "程序输出内容")