hello, I'm trying to make a couple of functions that add lines to the end of
a QTextEdit window.  one to add html and one to add text.  it's not working
and i can't figure out why or how to get around it.  it doesn't seem to make
any sense.
here's my code.

  def addline(self, text):                                        #for plain
text
    c = QTextCursor(self.output.document())
    c.setPosition(c.End)
    c.insertHtml('<font color="green">')
    c = QTextCursor(self.output.document())
    c.setPosition(c.End)
    stb = self.vs.value() == self.vs.maximum()
    if self.output.toPlainText():
      c.insertText('\n'+text)
    else:
      c.insertText(text)
    if stb:
      self.vs.setValue(self.vs.maximum())
    c = QTextCursor(self.output.document())
    c.setPosition(c.End)
    c.insertHtml('</font>')


  def addlinef(self, html):                            #for html
    c = QTextCursor(self.output.document())
    c.setPosition(c.End)
    stb = self.vs.value() == self.vs.maximum()
    if self.output.toPlainText():
      c.insertHtml("<br/>"+html)
    else:
      c.insertHtml(html)
    if stb:
      self.vs.setValue(self.vs.maximum())

some of the "c = QTextCursor(self.output.document())" and some of the
 "c.setPosition(c.End)" may be redundant; i put them there for defensive
programming to try to get this thing working.

the problems are
1. i can't get the plain text lines to show up green.
2. everything shows up in backward order. it's as if c.setPosition(c.End)
has no effect.

thx
_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to