I've been searching all over google and have found no solution, which is unbelievable! It should be simple. I'm trying to make my PyQT UI open a text file into a QTextBrowser or a QTextEdit.
But QTextEdit can't 'setSource' and QTextBrowser can not display anything but HTML, if I open the text file it doesn't have any of the paragraphing, it's all one line. This area will also display log files and I do NOT want my log files being output in html!
All I want to do is display the contents of a text file with plain text formatting. Why is this so stupidly hard??
text_edit = QPlainTextEdit()
...
text=open('file.txt').read()
text_edit.setPlainText(text)
Doesn't seem hard to me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With