-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpform.py
executable file
·66 lines (51 loc) · 2.08 KB
/
helpform.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
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python
# Copyright (c) 2007-8 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import qrc_resources
class HelpForm(QDialog):
def __init__(self, page, parent=None):
print 'In init of HelpForm'
super(HelpForm, self).__init__(parent)
self.setAttribute(Qt.WA_DeleteOnClose)
self.setAttribute(Qt.WA_GroupLeader)
backAction = QAction(QIcon(":/back.png"), "&Back", self)
backAction.setShortcut(QKeySequence.Back)
homeAction = QAction(QIcon(":/home.png"), "&Home", self)
homeAction.setShortcut("Home")
self.pageLabel = QLabel()
toolBar = QToolBar()
toolBar.addAction(backAction)
toolBar.addAction(homeAction)
toolBar.addWidget(self.pageLabel)
self.textBrowser = QTextBrowser()
layout = QVBoxLayout()
layout.addWidget(toolBar)
layout.addWidget(self.textBrowser, 1)
self.setLayout(layout)
self.connect(backAction, SIGNAL("triggered()"),
self.textBrowser, SLOT("backward()"))
self.connect(homeAction, SIGNAL("triggered()"),
self.textBrowser, SLOT("home()"))
self.connect(self.textBrowser, SIGNAL("sourceChanged(QUrl)"),
self.updatePageTitle)
self.textBrowser.setSearchPaths(["help/"])
self.textBrowser.setSource(QUrl(page))
self.resize(400, 600)
self.setWindowTitle("%s Help" % QApplication.applicationName())
def updatePageTitle(self):
self.pageLabel.setText(self.textBrowser.documentTitle())
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
form = HelpForm("index.html")
form.show()
app.exec_()