PyQT Reading a text file

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??

Answers


text_edit = QPlainTextEdit()
...
text=open('file.txt').read()
text_edit.setPlainText(text)

Doesn't seem hard to me.


Need Your Help

Yii login error when trying to do authentication against a user db table

php login yii

I am pretty new in Yii, and I am following the famous blog tutorial. However, I'm having a problem with user authentication. User authentication is performed in a class implementing the [IUserIdent...

HTACCESS REWRITE: Ignore Language code and add index.php to the url without changing it

php apache .htaccess codeigniter mod-rewrite

I am using the following rules to redirect the url with language code(en, fr, etc.) to url without it but added index.php before any segments. But it doesn't work as expected.