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
|
class Aide(QtGui.QWidget):
def __init__(self, nomFicAide, param=None, parent=None):
super(Aide, self).__init__(parent)
self.setWindowTitle(u"Help")
self.resize(800, 600)
# Give it a layout
self.layout = QtGui.QVBoxLayout(self)
self.layout.setContentsMargins(0, 0, 0, 0)
self.setLayout(self.layout)
# METHOD 1
# Create and fill QWebEngineView
self.view = QWebEngineView()
self.view.load(QtCore.QUrl.fromLocalFile(nomFicAide))
#TODO: jump to anchor
print("location.hash = '#" + param + "';")
self.view.page().runJavaScript("location.hash = '#" + param + "';")
# # METHOD 2
# # Create and fill QTextEdit
# self.view = QtGui.QTextEdit()
## self.view.setReadOnly(True)
# self.view.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse)
#
# _f = QtCore.QFile(nomFicAide)
# _f.open(QtCore.QFile.ReadOnly|QtCore.QFile.Text)
# _istream = QtCore.QTextStream(_f)
# self.view.setHtml(_istream.readAll())
# try:
# self.view.scrollToAnchor(param)
# except:
# pass
# _f.close()
# # METHOD 3
# # Create and fill QTextBrowser
# self.view = QtGui.QTextBrowser()
# _f = QtCore.QFile(nomFicAide)
# _f.open(QtCore.QFile.ReadOnly|QtCore.QFile.Text)
# _istream = QtCore.QTextStream(_f)
# self.view.setHtml(_istream.readAll())
# try:
# self.view.scrollToAnchor(param)
# except:
# pass
# _f.close()
# Add the QWebView to the layout
self.layout.addWidget(self.view) |
Partager