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.<div>
<br></div><div>here's my code.</div><div><br></div><div><div> def addline(self, text): #for plain text</div><div> c = QTextCursor(self.output.document())</div><div> c.setPosition(c.End)</div>
<div> c.insertHtml('<font color="green">')</div><div> c = QTextCursor(self.output.document())</div><div> c.setPosition(c.End)</div><div> stb = self.vs.value() == self.vs.maximum()</div>
<div> if self.output.toPlainText():</div><div> c.insertText('\n'+text)</div><div> else:</div><div> c.insertText(text)</div><div> if stb:</div><div> self.vs.setValue(self.vs.maximum())</div>
<div> c = QTextCursor(self.output.document())</div><div> c.setPosition(c.End)</div><div> c.insertHtml('</font>')</div><div> </div><div> </div><div> def addlinef(self, html): #for html</div>
<div> c = QTextCursor(self.output.document())</div><div> c.setPosition(c.End)</div><div> stb = self.vs.value() == self.vs.maximum()</div><div> if self.output.toPlainText():</div><div> c.insertHtml("<br/>"+html)</div>
<div> else:</div><div> c.insertHtml(html)</div><div> if stb:</div><div> self.vs.setValue(self.vs.maximum())</div><div><br></div><div>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.</div>
<div><br></div><div>the problems are </div><div>1. i can't get the plain text lines to show up green. </div><div>2. everything shows up in backward order. it's as if c.setPosition(c.End) has no effect.</div><div>
<br></div><div>thx</div><div><br></div><div><br></div></div>