title: Displaying a function output directly to a QtextBrowser
body: <p>im fairly new to coding even more at object oriented python so please bear with me.</p>
  
  <p>Im trying to build a GUI for a program i coded before using PyQt5.
  I've designed my forms at Qt Designer then used <code>python -m PyQt5.uic.pyuic -x [FILENAME].ui -o [FILENAME].py</code> to get the file as .py.</p>
  
  <p>in order to avoid to change the file, im using another python file to call the form.py file and my program.py and build everything there</p>
  
  <pre><code>import sys 
  from myform import Ui_MainWindow
  from mydialog1 import Ui_Dialog as Dlog_1
  from mydialog2 import Ui_Dialog as Dlog_2
  from PyQt5 import QtCore, QtGui, QtWidgets
  from myprogram import *
  
  class Prog(QtWidgets.QMainWindow, Ui_MainWindow):
  
      def __init__(self):
          super(Prog, self).__init__()
          self.ui = Ui_MainWindow()
          self.ui.setupUi(self)
          self.show()
  
          self.ui.actionAbout.triggered.connect(self.about)
  
          self.ui.textBrowser.append(show())
  
      def about(self):
          dialog = QtWidgets.QDialog()
          dialog.ui = Dlog_1()
          dialog.ui.setupUi(dialog)
          dialog.ui.Adicionar_3.clicked.connect(dialog.close)
          dialog.setAttribute(QtCore.Qt.WA_DeleteOnClose)
          dialog.exec_()
  
  
  if __name__ == "__main__":
      app = QtWidgets.QApplication(sys.argv)
      MainWindow = Prog()
      MainWindow.show()
      sys.exit(app.exec_())
  </code></pre>
  
  <p>Im trying to display the output from a function (from myprogram) to a QTextBrowser widget as it can be seen <code>self.ui.textBrowser.append(show())</code> although this works with plain text for example ("test") it wont work with a function.</p>
  
  <p>the function show() is defined as the following</p>
  
  <pre><code>def show():
      global empresas
      info = ["Nome da empresa", "Site da empresa", "Montante investido"]
      valid = False
      while not valid:
          try:
              gen = ((k, v[0], v[1]) for k, v in empresas.items())
              ename, esite, evalue = zip(*gen)
              valid = True
          except ValueError:
              print('Não existem empresas para mostrar. Introduza mais empresas')
              return
      print("")
      a = ('|{}{:^30}{}| |{}{:^30}{}| |{}{:^30}{}|'.format(c['g'],info[0],c['d'],c['g'],info[1],c['d'],c['g'],info[2],c['d']))
      print("+" + "=" * (len(a)-32) + "+")
      print(a)
      print("+" + "=" * (len(a)-32) + "+")
      for y in range(0,len(ename)):
         if y % 2 == 0:   
             print(f'|{ename[y]:^30}| |{esite[y]:^30}| |{evalue[y]:^17.3f}Milhões de',simb, '|') 
             print("+" + "-" * (len(a)-32) + "+")
         elif y % 2 == 1:
             print(f'|{ename[y]:^30}| |{esite[y]:^30}| |{evalue[y]:^17.3f}Milhões de',simb, '|') 
             print("+" + "-" * (len(a)-32) + "+") 
      return
  </code></pre>
  
  <p>This function basicly prints an organized table with all the items from a dictionary to the console.
  Is there a way that allows me to print the same type of output to a QtextBrowser as it would look on the console?</p>
  
  <p>Thanks in advance</p>