I figured out the problem with everything coming in reverse order. i needed movePosition instead of setPosition. that seems to fix the color issue also. i guess it's working fine so far, thanks anyway!
On Thu, Oct 8, 2009 at 3:47 AM, inhahe <[email protected]> wrote: > 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
