title: Trying to produce monospaced output in pyqt browser
body: <p>I have modified a short piece of pyqt code to produce real-time rendering of a user's expression. I have used sympy's pretty-printing function for this, however the output does not appear correctly as the QTextBrowser uses a proportional rather than a monospaced font.</p>
  
  <p>As a beginner I would also welcome any other thoughts you had on the code.</p>
  
  <p>Many thanks and best wishes,
  Geddes</p>
  
  <pre><code>from __future__ import division
  import sys
  import sympy
  from PyQt4.QtCore import *
  from PyQt4.QtGui import *
  
  class Form(QDialog):
      def __init__(self, parent=None):
          super(Form, self).__init__(parent)
          self.browser = QTextBrowser()
          self.lineedit = QLineEdit("please type an expression")
          self.lineedit.selectAll()
          layout = QVBoxLayout()
          layout.addWidget(self.browser)
          layout.addWidget(self.lineedit)
          self.setLayout(layout)
          self.lineedit.setFocus()
          self.connect(self.lineedit, SIGNAL("textChanged (const QString&amp;)"),self.updateUi)
  
      def updateUi(self):
          text = unicode(self.lineedit.text())
          for z in range(0,9):
              text = text.replace('x'+str(z),'x^'+str(z))
              text = text.replace(')'+str(z),')^'+str(z))
              text = text.replace(str(z)+'x',str(z)+'*x')
              text = text.replace(str(z)+'(',str(z)+'*(')
          try:
              self.browser.append(sympy.printing.pretty(sympy.sympify(text)))
              self.browser.clear()
              self.browser.append(sympy.printing.pretty(sympy.sympify(text)))
          except:
              if text=='': self.browser.clear()
  
  app = QApplication(sys.argv)
  form = Form()
  form.show()
  app.exec_()
  </code></pre>