-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove qtassistant and reduce size of mantiddocs package #37248
Comments
A Case for
|
QtWebEngine needs to get imported before the QApplication is created. This will have to happen in the startup code for workbench. To see the error from qtpy import QtWidgets, QtCore
QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_ShareOpenGLContexts)
app = QtWidgets.QApplication([''])
from qtpy.QtWebEngineWidgets import QtWebChannel, QWebEngineView reversing the order of the last two lines fixes the issue. |
Here is a prototype for this implementation. Please look at the attached files. There is still some work to be done to find the solution between good rendering of the equations and retaining the layout of the doc pages. Please take a look at these:Scriptimport sys
import os
from PyQt5.QtCore import QUrl
from PyQt5.QtWidgets import QApplication, QVBoxLayout, QWidget, QPushButton
from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEngineSettings
from PyQt5.QtWebEngineCore import QWebEngineUrlRequestInterceptor
from http.server import SimpleHTTPRequestHandler, HTTPServer
import threading
class MyRequestInterceptor(QWebEngineUrlRequestInterceptor):
def interceptRequest(self, info):
url = info.requestUrl()
if url.host() == "cdn.jsdelivr.net":
info.setHttpHeader(b"Access-Control-Allow-Origin", b"*")
class HelpWindow(QWidget):
def __init__(self, rootDir, parent=None):
super().__init__(parent)
self.setWindowTitle('Mantid Help Window')
self.setGeometry(300, 100, 1200, 800)
# Assuming the HTML files are directly in the rootDir
self.convertDiffcalPath = "http://localhost:8000/ConvertDiffCal.html"
self.anotherPagePath = "http://localhost:8000/EstimateResolutionDiffraction.html"
layout = QVBoxLayout(self)
self.webView = QWebEngineView()
# Create and set the request interceptor
interceptor = MyRequestInterceptor()
self.webView.page().profile().setUrlRequestInterceptor(interceptor)
layout.addWidget(self.webView)
self.toggleButton = QPushButton('Go to another page')
self.toggleButton.clicked.connect(self.togglePage)
layout.addWidget(self.toggleButton)
self.currentPage = 'convertDiffcal'
self.loadPage(self.convertDiffcalPath)
def loadPage(self, url):
self.webView.setUrl(QUrl(url))
def togglePage(self):
if self.currentPage == 'convertDiffcal':
self.loadPage(self.anotherPagePath)
self.currentPage = 'anotherPage'
self.toggleButton.setText('Go back to first page')
else:
self.loadPage(self.convertDiffcalPath)
self.currentPage = 'convertDiffcal'
self.toggleButton.setText('Go to another page')
def startLocalServer(rootDir):
os.chdir(rootDir)
handler = SimpleHTTPRequestHandler
httpd = HTTPServer(('localhost', 8000), handler)
httpd.serve_forever()
if __name__ == '__main__':
if len(sys.argv) < 2:
print("Usage: python script.py /path/to/docs/html/")
sys.exit(1)
ROOT_DIR = sys.argv[1]
# Start the local server in a separate thread
serverThread = threading.Thread(target=startLocalServer, args=(ROOT_DIR,), daemon=True)
serverThread.start()
app = QApplication(sys.argv)
# Launch the Help Window
mainWin = HelpWindow(ROOT_DIR)
mainWin.show()
sys.exit(app.exec_()) |
boost::python 1.84 docs for calling python functions and methods |
The current mantid help system uses qtassistant to show the help documentation. This method of including the docs is always in agreement with the code. However, there are some problems with this approach:
Describe the solution you'd like
Describe alternatives you've considered
qtwebview might be able to do it
Additional context
The text was updated successfully, but these errors were encountered: