-
Notifications
You must be signed in to change notification settings - Fork 0
/
help_.py
54 lines (41 loc) · 1.09 KB
/
help_.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
import sys
from PyQt4 import QtGui, QtCore
from PyQt4.QtWebKit import QWebView
import markdown
import codecs
class Win(QtGui.QMainWindow):
def __init__(self, text, style):
super(Win, self).__init__()
with open(style) as f:
style = f.read()
with open(text) as f:
mrkDn = f.read()
html = markdown.markdown(mrkDn)
self.html = (
'<!DOCTYPE html>\n\n'
'<html>\n'
'\t<head>\n'
'\t\t<title>Help</title>\n'
'\t\t<style>\n\n'
) + style + (
'\n\n\t</style>\n'
'\t</head>\n'
'\t<body>\n\n'
) + html + (
'\n\n\t</body>\n'
'</html>\n'
)
self.initUI()
def initUI(self):
view = QWebView()
view.setHtml(self.html)
self.setCentralWidget(view)
self.resize(450, 550)
self.setWindowTitle('Help')
def main():
app = QtGui.QApplication(sys.argv)
win = Win('help.md', 'help.css')
win.show()
sys.exit(app.exec_())
if __name__ == '__main__':
main()