-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewer.py
56 lines (49 loc) · 1.84 KB
/
viewer.py
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from PyQt4 import QtGui
import sys
import settings
import exam_result
import testcodec
class ViewerWindow(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QMainWindow.__init__(self, parent)
self.results_base = exam_result.ResultsBase()
self.prepare()
def prepare(self):
self.layout = QtGui.QHBoxLayout()
self.fsm = QtGui.QFileSystemModel()
self.fsm.setRootPath(settings.READER_REPORTS)
cw = QtGui.QWidget()
self.setCentralWidget(cw)
self.report_tree = QtGui.QTreeView()
self.report_tree.setModel(self.fsm)
self.report_tree.setRootIndex(self.fsm.index(settings.READER_REPORTS))
self.report_tree.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
self.report_tree.selectionModel().selectionChanged.connect(self.show_report)
self.report_tree.hideColumn(1)
self.report_tree.hideColumn(2)
self.report_tree.hideColumn(3)
self.report_view = QtGui.QTextEdit()
self.layout.addWidget(self.report_tree)
self.layout.addWidget(self.report_view)
self.centralWidget().setLayout(self.layout)
def show_report(self, selected, deselected):
idx = selected.indexes()[0]
filename = self.fsm.filePath(idx)
print(filename)
if not filename.endswith('.rep'):
return
f = open(filename)
key = f.readline()
encoded_text = f.read()
f.close
plain_text = testcodec.decode_text(encoded_text, key)
self.report_view.setText(plain_text)
def day_summary(self, path):
s = ''
#for r in results:
# s = s + ' '.join(r) + '\n'
self.report_view.setText(s)
app = QtGui.QApplication(sys.argv)
viewer = ViewerWindow()
viewer.show()
sys.exit(app.exec_())