|
| 1 | +from PyQt4 import QtCore, QtGui, QtWebKit |
| 2 | +from PyQt4.QtCore import * |
| 3 | +from PyQt4.QtGui import * |
| 4 | + |
| 5 | +class InteractiveHTMLViewerDialog(QtGui.QDialog): |
| 6 | + |
| 7 | + def __init__(self, html, linkHandler): |
| 8 | + QtGui.QDialog.__init__(self) |
| 9 | + self.html = html |
| 10 | + self.linkHandler = linkHandler |
| 11 | + self.setModal(True) |
| 12 | + self.setupUi() |
| 13 | + |
| 14 | + def setupUi(self): |
| 15 | + self.resize(600, 500) |
| 16 | + self.webView = QtWebKit.QWebView() |
| 17 | + self.webView.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks) |
| 18 | + self.setWindowTitle("Help") |
| 19 | + self.closeButton = QtGui.QPushButton() |
| 20 | + self.closeButton.setText("Close") |
| 21 | + self.closeButton.setMaximumWidth(150) |
| 22 | + self.horizontalLayout= QtGui.QHBoxLayout() |
| 23 | + self.horizontalLayout.setSpacing(2) |
| 24 | + self.horizontalLayout.setMargin(0) |
| 25 | + self.horizontalLayout.addStretch(1000) |
| 26 | + self.horizontalLayout.addWidget(self.closeButton) |
| 27 | + self.verticalLayout= QtGui.QVBoxLayout() |
| 28 | + self.verticalLayout.setSpacing(2) |
| 29 | + self.verticalLayout.setMargin(0) |
| 30 | + self.verticalLayout.addWidget(self.webView) |
| 31 | + self.verticalLayout.addLayout(self.horizontalLayout) |
| 32 | + self.setLayout(self.verticalLayout) |
| 33 | + QObject.connect(self.closeButton, QtCore.SIGNAL("clicked()"), self.closeWindow) |
| 34 | + QObject.connect(self.webView, SIGNAL("linkClicked(const QUrl&)"), self.linkClicked) |
| 35 | + try: |
| 36 | + url = QtCore.QUrl(self.filename) |
| 37 | + self.webView.load(url) |
| 38 | + except: |
| 39 | + pass |
| 40 | + |
| 41 | + def linkClicked(self, url): |
| 42 | + pass |
| 43 | + |
| 44 | + |
| 45 | + def closeWindow(self): |
| 46 | + self.close() |
0 commit comments