04-10-2022, 12:15 PM | #1 |
Grand Sorcerer
Posts: 28,040
Karma: 199464182
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Sigil Qt6 and GUI plugin development changes
You may or may not know that Sigil is planning to move from Qt5 to Qt6 in a near-future release. This will effect plugins that currently utilize PyQt5 for their GUI interfaces. Note that plugins that use tkinter, or don't use a GUI interface will be unaffected by this change.
For all plugin devs whose plugins will be affected: For reasons that are not really up for debate, Sigil has chosen to move to PySide6 for its preferred Python wrapper to Qt in the bundled Python that comes with the Windows and macOS Sigil packages. In order to maintain compatibility with older versions of Sigil (Qt5/PyQt5) and newer versions of Sigil (Qt6/PySide6), I've come up with a compatibility module that can be included in your plugin to make things easier. If you don't update your plugin, you and your users will still have the option of using an external Python with PyQt5 installed for your plugin. No one will be left completely out in the cold. You can also use your own homegrown solution to remain compatible with Sigil-Qt5 and Sigil-Qt6. There are less differences than you would think between PyQt5 and PySide6. And where there are differences, I've coded some helper utilities in the plugin_utils module to facilitate things. The plugin_utils module can be found in my personal github repository for it. I use the module extensively in my own TagMechanic plugin (which has been updated to work with PyQt5 and PySide6), so feel free to use it as an example. I've also made a Sigil Qt Plugin template that makes use of the plugin_utils module so that is another resource for plugin devs to modify their Gui Qt plugins. It's full of comments in the code to explain what is happening. Several of @Doitsu's GUI plugins have already been updated to work with the coming change to Sigil as well. His Epub2LegacyMetaData plugin alone makes use of nearly all of the features of the plugin_utils module. So make use of his code examples as well. Our own EPUB3 reader plugins have also been updated. That code is available for your perusal. And of course myself and Kevin will be able to offer advice to those plugin devs who may run into trouble accommodating the upcoming changes. Last edited by DiapDealer; 04-11-2022 at 12:23 PM. |
04-10-2022, 12:24 PM | #2 |
Grand Sorcerer
Posts: 28,040
Karma: 199464182
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
In order to assist plugin devs in their testing, we have beta Qt6 versions of Sigil (for Windows and macOS) that can be installed at the same time as the regular release (Qt5) version of Sigil.
We've gone to great lengths to make sure these betas are safe, but please back up your Sigil preferences/INIs just to be safe. Sigil-2.0.0-Windows-Qt6-Beta-x64-Setup.exe A pre-release Qt6 Beta version of Sigil-2.0.0 for Mac (x86_64) These betas may change from time to time. Last edited by KevinH; 08-05-2023 at 11:19 AM. |
Advert | |
|
04-11-2022, 11:35 AM | #3 |
Grand Sorcerer
Posts: 28,040
Karma: 199464182
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
All links and announcements seem to check out, so I'm going to open the thread to comments/questions. Please try to limit the discussion to questions about (or improvements to) the plugin_utils module, or specific questions about how to modify plugin code to work with both PyQt5/PySide6.
|
12-12-2022, 10:50 AM | #4 |
Grand Sorcerer
Posts: 5,640
Karma: 23191067
Join Date: Dec 2010
Device: Kindle PW2
|
How to best handle import Pyside import errors
I've created a simple plugin that requires PySide.QWebEngineView, which isn't available in PyQt5. What's the most elegant way to handle Pyside import errors?
The following code works, but I'm also getting an Error Parsing Result XML. Start tag expected. error message. Code:
import sys try: from PySide.QtWebEngineWidgets import QWebEngineView # more PySide imports except ModuleNotFoundError: print('This plugin requires PySide.') sys.exit() Last edited by Doitsu; 12-12-2022 at 10:52 AM. |
12-12-2022, 12:05 PM | #5 |
Grand Sorcerer
Posts: 28,040
Karma: 199464182
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
It is my understanding that QWebEngineView is available in both PySide6 and PyQt5 via the QtWebEngineWidgets class:
Code:
from from PyQt5.QtWebEngineWidgets import QWebEngineView from from PySide6.QtWebEngineWidgets import QWebEngineView include plugin_utils from plugin_utils import QtWebEngineWidgets weview = QtWebEngineWidget.QWebEngineView() As for the "Error Parsing Result XML" ... that is a plugin launcher/wrapper error that typically occurs when there's an issue with the data being returned from the Python plugin process to Sigil's C++ routines. See any of the three Sigil ePub3 reader plugins (EpubJSReader, BibiReader, ReadiumReader) for examples of QWebEngineView being used in a plugin that supports both Qt5/PyQt5 and Qt6/PySide6 versions of Sigil. Last edited by DiapDealer; 12-12-2022 at 12:26 PM. |
Advert | |
|
12-12-2022, 12:11 PM | #6 |
Sigil Developer
Posts: 8,160
Karma: 5450818
Join Date: Nov 2009
Device: many
|
Not sure if this helps, but the PyQt5 PyQtWebEngine (separate module) module includes QWebEngineView under QWebEngineWidgets just like PySide6.
See for example on how to use it via the plugin_utils here: https://github.com/Sigil-Ebook/Readi.../plugin.py#L57 The Windows and macOS Sigil builds under Qt5 included it as part of the standard install beginning with Sigil 1.60 back in April of 2021. Last edited by KevinH; 12-12-2022 at 12:20 PM. |
12-12-2022, 12:28 PM | #7 |
Grand Sorcerer
Posts: 28,040
Karma: 199464182
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
The QWebEnginePage, QWebEngineProfile, QWebEngineScript, QWebEngineSettings modules moved from QtWebEngineWidgets in PyQt5 to QtWebEngineCore in PySide6, so if you need to use those in conjunction with QWebEngineView, you'll need to account for that, or just use the utility module which does it for you.
|
12-12-2022, 01:25 PM | #8 |
Grand Sorcerer
Posts: 5,640
Karma: 23191067
Join Date: Dec 2010
Device: Kindle PW2
|
Thanks for your helpful replies! The QWebEngineView is indeed available in both PySide6 and PyQt5 via the QtWebEngineWidgets class. I'll have another look at the code example by KevinH.
|
12-12-2022, 05:37 PM | #9 |
Grand Sorcerer
Posts: 28,040
Karma: 199464182
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Let us know if you run into trouble! The "Error Parsing Result XML" error can be difficult to debug at times. How the PyQt5 app/gui is deleted/destroyed can cause the plugin process to crash in the background with anything less than Qt5.14. It was a problem with PyQt up until Qt5.14.
In the off chance that that's the issue, just make sure to force the order of how objects get destroyed (after everything is all done) to work around it. Code:
del window, app |
08-05-2023, 11:22 AM | #10 |
Sigil Developer
Posts: 8,160
Karma: 5450818
Join Date: Nov 2009
Device: many
|
A Qt6 based pre-release of Sigil.app-2.0.0-Beta-Mac-x86_64.txz that can be used to test Qt based gui plugins on MacOS has been added to this post
https://www.mobileread.com/forums/sh...27&postcount=2 |
08-05-2023, 01:39 PM | #11 |
Grand Sorcerer
Posts: 5,640
Karma: 23191067
Join Date: Dec 2010
Device: Kindle PW2
|
If you're using one of the following plugins and want to test the Sigil Qt6 beta, please install the latest plugin versions that I uploaded today.
AddIDs Epub2LegacyMetaData KindleGenQt LanguageTool MarkdownImport ShowSemantics (Thanks to a special Python library that DiapDealer kindly provided, they're all backwards-compatible with previous Sigil 1.x versions.) Last edited by Doitsu; 08-07-2023 at 03:04 PM. |
08-05-2023, 02:13 PM | #12 |
Grand Sorcerer
Posts: 28,040
Karma: 199464182
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
My most popular Qt plugins should also be ready for Sigil 2.x and 1.x :
TagMechanic DOCXImport KindleImport I tried to indicate in the plugins' first posts that when Linux users upgrade to (or build) Sigil 2.0 with Qt6, they'll need to install PySide6 (to use these Qt plugins). Since Linux Sigil relies on the system Python for plugins. |
08-07-2023, 02:15 AM | #13 | ||
just an egg
Posts: 1,697
Karma: 5514284
Join Date: Mar 2015
Device: Kindle, iOS
|
Hi Doitsu,
I downloaded the new ShowSemantics and MarkdownImport plugins and installed on current Sigil 1.9.30 on macOS Ventura. ShowSemantics worked fine, however MarkdownImport threw the following error. On further testing, I also get an error with v0.1.2. Obviously I haven't used this plugin for a while. Anyway, let me know if the error is on my end and if so, how I fix it Spoiler:
Also, FYI to DiapDealer, I quickly tested the new TagMechanic, KindleImport and DOCXImport, which worked fine on 1.9.30 (i.e., backward compatiblility is fine) Quote:
Quote:
|
||
08-07-2023, 06:16 AM | #14 | |
Grand Sorcerer
Posts: 5,640
Karma: 23191067
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
Most likely, Ventura blocked the execution of that binary for security reasons and you'll need to manually mark it as safe. Hopefully, KevinH, can help you with this. |
|
08-07-2023, 10:28 AM | #15 |
Sigil Developer
Posts: 8,160
Karma: 5450818
Join Date: Nov 2009
Device: many
|
That or the plugin needs to mark that binary as having executable permission using os.chmod immediately before first run. I will take a peek at it.
I will need to add an arm64 binary for macos as well. KevinH |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[GUI Plugin] KindleUnpack - The Plugin | DiapDealer | Plugins | 495 | 10-19-2024 07:06 AM |
[GUI Plugin] Noosfere_util, a companion plugin to noosfere DB | lrpirlet | Plugins | 2 | 08-18-2022 04:15 PM |
[GUI Plugin] Save Virtual Libraries To Column (GUI) | chaley | Plugins | 14 | 04-04-2021 06:25 AM |
[GUI Plugin] Plugin Updater **Deprecated** | kiwidude | Plugins | 159 | 06-19-2011 01:27 PM |