forked from audreyfeldroy/sphinx-gui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditor.py
More file actions
25 lines (18 loc) · 704 Bytes
/
editor.py
File metadata and controls
25 lines (18 loc) · 704 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from PySide import QtCore, QtGui
class Editor(QtGui.QTextEdit):
def __init__(self, parent=None):
super(Editor, self).__init__(parent)
self.setMinimumWidth(550)
# TODO: resize editor proportionally.
# For now, max width is hardcoded.
def open_file(self, file_path):
inFile = QtCore.QFile(file_path.absolute())
if inFile.open(QtCore.QFile.ReadOnly | QtCore.QFile.Text):
text = inFile.readAll()
try:
# Python v3.
text = str(text, encoding='ascii')
except TypeError:
# Python v2.
text = str(text)
self.setPlainText(text)