-
Notifications
You must be signed in to change notification settings - Fork 243
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
Use QtWebEngine instead of deprecated QtWebView #116
Conversation
One bug found. When I tried to get a preview of sample project on Linux, first I get:
Why? It does not seem Qt-related? But then it results in:
And yes, |
Following are the results of testing this PR on the following platforms: a) Windows XP with Python 3.4.4 and PyQt v5.5.1 Unfortunately manuskript failed to run on both of the above platforms. ;-( The error message:
So far I have been unable to find QtWebEngine packages for the above versions. I also discovered the following message on Deploying Qt WebEngine Applications.
Based on these findings I think if we are to implement QtWebEngine then we will need a solution that can also continue to use QtWebView. Perhaps there is a way with Python to conditionally use one or the other? |
The unicode bug is fixed. I could not install QtWebEngine, so I wasn't able to test your PR. But using your code, I tried a solution so that manuskript can use either QtWebKit, QtWebEngine, or none if none is available. Would you mind testing it, both of you? Thanks. |
Hop, I realised I could commit on your branch in your repo. Great ! I commented out the import before the qApplication because I could find no references to that. Where do you see this as necessary? That seems strange to me. |
TLDR - To Long Didn't Read;
EDIT 2017-06-16:
It appears the ubuntu 17.04 has both python-pyqt5.qtwebkit and python-pyqt5.qtwebengine packages. Hence to test I removed qtwebkit and installed qtwebengine. With QtWebEngine installed:
The results have been updated below. PREPARATIONOn *buntu ensure:
On Ubuntu 17.04 ensure:
On Windows XP ensure:
TESTINGEnvironments
StepsThe steps I used for testing the feature/QtWebEngine branch are as follows:
RESULTS
[1] Preview pane contains blank / empty screen. No story contents visible. [2] Preview pane contains blank / empty screen. No story contents visible. [3] Preview pane contains the following text:
SUMMARYBased on my testing:
Most of the features worked. However, both QtWebKit and QtWebEngine failed to provide a preview of the Pandoc PDF. I think this is a very minor issue because the Pandoc PDF export did work. With respect to the Pandoc HTML preview failing to work with QTWebEngine, I think this is a minor issue because the Manuskript HTML preview does work. Hopefully @katafrakt can provide results from testing with QtWebEngine on Mac OS X. |
Great report! From what I read, it does not exactly work when webkit is installed, because preview doesn't work, though it should. Is that right? |
@olivierkes that is correct. The preview pane is blank (in fact it shows a black screen) when I select Pandoc - PDF. Regarding QtWebEngine, I will see if I can find a GNU/Linux distribution that has packages for QtWebEngine so I can test this code path as well. |
It turns out that Ubuntu 17.04 has both python-pyqt5.qtwebkit and python-pyqt5.qtwebengine packages. Hence to test I removed qtwebkit and installed qtwebengine. RESULTS
[1] Preview pane contains blank / empty screen. No story contents visible. [2] Preview pane contains blank / empty screen. No story contents visible. [3] Preview pane contains the following text:
See also the updated testing results that are posted earlier in this thread. Hopefully @katafrakt can provide results from testing with QtWebEngine on Mac OS X. |
I'll test MacOS + arch (it worked for me with QtWebEngine before) later today or tomorrow and will get back to you. |
When running the features/QtWebEngine branch with TEST B (preview of Pandoc HTML) the following messages appear in the terminal window:
'Looks like we might need a different HTML call for QtWebEngine.... |
As for this question:
Without that I'm getting this error:
Here's possible explanation: https://riverbankcomputing.com/pipermail/pyqt/2016-August/037928.html |
@gedakc Regarding your last comment - the listing you pasted says |
Here are results of my tests:
Notes[1] Empty container for PDF file is visible, message in console says:
[2] Same as above, but without any message In both cases, I think I'm missing something obvious to get it to work. Other notesI tested both I have to reenable early import of To test on Linux, I had to alter #!/usr/bin/env python
# --!-- coding: utf8 --!--
import PyQt5
import os
features = {'qtwebkit': False, 'qtwebengine': False}
if 'QT_WEB' in os.environ:
features[os.environ['QT_WEB']] = True
else:
try:
import PyQt5.QtWebKitWidgets
features['qtwebkit'] = True
except:
features['qtwebkit'] = False
try:
import PyQt5.QtWebEngineWidgets
features['qtwebengine'] = True
except:
features['qtwebengine'] = False
if features['qtwebkit']:
from PyQt5.QtWebKitWidgets import QWebView
print("Debug: Web rendering engine used: QWebView")
webEngine = "QtWebKit"
webView = QWebView
elif features['qtwebengine']:
from PyQt5.QtWebEngineWidgets import QWebEngineView
print("Debug: Web rendering engine used: QWebEngineView")
webEngine = "QtWebEngine"
webView = QWebEngineView
else:
from PyQt5.QtWidgets import QTextEdit
print("Debug: Web rendering engine used: QTextEdit")
webEngine = "QTextEdit"
webView = QTextEdit Hope this helps. |
Thanks @katafrakt for testing and for the tip that QtWebEngineWidgets must be imported before a QCoreApplication instance is created. I was successfully able to view a TEST B Pandoc - HTML preview on Ubuntu 17.04 after adding the following line:
Note that we'll need to do a conditional import in the code so that both QtWebKit and QtWebEngine will work. |
Sure thing. I'd love to see it as part of some global |
My preference is to follow the KISS philosophy, and simply try to load one first, and if that fails then try to load the other. That way we don't burden our users with trying to figure out why they should choose one over the other. In fact they might not even have a choice if QtWebKit is left out of new PyQt packages. Is there an advantage of using one versus the other? If so, then we could try to load the advantageous one first, whichever that might be: QtWebKit or QtWebEngine. |
I've created a new feature/QtWebEngine-v2 branch that conditionally loads QtWebKitWidgets and QtWebEngineWidgets in the same order as used in manuskript/ui/views/webView.py. Using this branch I have the same testing results as @katafrakt noted 4 posts earlier. On Ubuntu 17.04 with QtWebEngine when trying TEST C Pandoc - PDF preview, I also see a blank pane in manuskript, and see the following message in my terminal window:
It seems we are missing something needed by QtWebEngine for a PDF preview. It is possible that the same "missing something" might make PDF preview work for QtWebKit as well. |
I came across the following mention of this issue: pdfjs-dist 1.3.94 throwing error It appears that the work-around implemented was to roll back to an earlier version. Because manuskript has |
PDF preview works for me in the current Can you please confirm that PDF preview doesn't work with
I cannot reproduce
Not sure what you mean by that, sorry ;) For now, I updated I cannot find an easy way to install qtwebengine on Linux Mint 18.1, so I'm working blind here. If that works, then we can can maybe merge that, and open a bug report for the PDF preview issue, which seems unconnected. |
Following are my recent test results using @olivierkes develop and feature/QtWebEngine branches.
[1] Preview pane contains blank / empty screen. No console error message. [2] Manuskript fails to run because no QtWebKit installed. Only QtWebEngine installed.
[3] Preview pane contains blank / empty screen. Console has error message:
@olivierkes, for testing you might consider setting up a Virtual Machine with a newer OS that has the QtWebEngine package. My guess is that you'll need to have at least 4 GB RAM and 20+ GB free space in a file system to run a VM. On Ubuntu/Mint, you can install VirtualBox with:
Then you could install an OS familar to you with steps similar to the following: Next I plan to investigate using an older version of pdfjs. |
I believe I have discovered the reason why Test C Pandoc PDF preview does not work for @katafrakt or me. It is because the The .gitignore file contains an entry for To fix this issue I think if @olivierkes adds this missing To commit the
EDIT: Note that we should also include the BACKGROUND RESEARCH I tested several versions of pdf.js including the latest stable release pdfjs-1.7.225. All of these versions worked for all features including Test C Pandoc PDF preview. When comparing these versions to @olivierkes code, I noticed that the feature/QtWebEngine branch was missing the EDIT: If you wish to try out these tests with the full pdfjs-1.3.91 installed including |
Of course !! Thanks for finding that. See the updated branch now, with missing files, including license. Everything should work now I guess. |
Thank you @olivierkes for committing the missing files/directories. Following are my latest test results using the feature/QtWebEngine branch.
[1] PDF Preview works. However many messages displayed on console. Example of 198 lines of console messages:
I can provide a complete list of the console messages if needed. |
No thanks, I guess it's unnecessary. There might be a way to turn those
warnings off. I'll check that later on.
|
@katafrakt, does the updated features/QtWebEngine branch work for you on MacOS and/or Arch Linux? |
@olivierkes, @gedakc Hello again! First of all I'm terribly sorry for having abandoned this topic for such a long time. This was cause by my laptop breakdown at first and then I simply forgot about this issue. Anyway, I retested I also tested on Mac, but only I would like to suggest to proceed: choose which branch to clean up and merge it, maybe release. Then perhaps we can start working on packaging Manuskript for Mac? I think I like code in |
Thank you @katafrakt for testing and posting your results. I am in agreement to proceed with the code in I am favour of including other open PRs as well and then creating a new release. With @katafrakt offering to build the MacOS image, then I offer to build the Windows and Linux PyInstaller images. |
Just to be clear: I have no experience in building MacOS releases. I only briefly researched the topic and it seem not impossible. I volunteer to look more into it, however assumption that I will succeed may be a bit far-fetched 😉 |
@katafrakt, we have some instructions on building packages in the Manuskript Wiki that may help. |
I tried that yesterday and today, but with no luck. It seems it needs some tweaking. I'll let you know if I find a solution. |
I've had good results using PyInstaller on both Linux and Windows. PyInstaller is listed as being supported on Mac OS X as well. |
I merged the Is it worth mergin @gedakc's |
@olivierkes, please do not merge my feature/QtWebEngine-v3 branch. It has been long enough since I created the branch that I no longer remember the differences. I will remove my feature/QtWebEngine-v2 and feature/QtWebEngine-v3 branches. |
@katafrakt does the features/QtWebEngine code that is committed to the develop branch work for you? If so then we should probably close this PR. |
@gedakc I have just done a re-check. There are some problems with PDF preview because I apparently broke TeX installation on my computer, but generally things seem to work. I only needed to set pandoc PDF engine to xelatex manually. I'm closing the PR. |
may I ask how to suppress these warnings? :) |
As mentioned in #54, QtWebKit was deprecated and is now removed from Qt releases. Although there is apparently some effort being made to reinstate it, right now it results in complicated build process to get Manuscript working (see #35). And since it uses QtWebKit only to render HTML and PDF previews, it is fairly easy to rewrite it using QtWebKit's successor: QtWebEngine.
This PR makes it.
However, note that I only tested it with HTML preview now (it worked). I need to fix my LaTeX installation to test it with PDFs. Also, any clues on testing would be most welcome.
With QtWebEngine instead of QtWebKit, it's possible to build Manuscript against standard binary distribution of Qt from Homebrew and I suppose it's also easier on some Linux distributions. I don't have a chance right now to check it on Windows.