From 09bf97c38e04c7ade7d37ef5c57e56fd5abe8ea2 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 27 Sep 2024 10:00:58 -0500 Subject: [PATCH] Migrate to Qt6 and PySide6 --- pyproject.toml | 8 ++++---- webappify/__init__.py | 24 +++++++++++------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f9b2aad..cfb17d1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,6 +15,7 @@ authors = [ ] keywords = [ "Qt", + "Qt6", "website", ] classifiers = [ @@ -27,16 +28,15 @@ classifiers = [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Desktop Environment", "Topic :: Internet :: WWW/HTTP :: Browsers", "Topic :: Software Development :: Libraries :: Python Modules", ] dependencies = [ - "PyQt5", - "PyQtWebEngine", + "PySide6", ] dynamic = [ "version", diff --git a/webappify/__init__.py b/webappify/__init__.py index 49d0569..b7b8847 100644 --- a/webappify/__init__.py +++ b/webappify/__init__.py @@ -2,8 +2,8 @@ WebAppify ========= -WebAppify is a simple module to easily create your own desktop apps of websites. WebAppify uses PyQt5 and QtWebKit or -QtWebEngine for displaying the web page, and works on Python 2.7 and Python 3.4 and up. +WebAppify is a simple module to easily create your own desktop apps of websites. WebAppify uses PySide6 and +QtWebEngine for displaying the web page, and works on Python 3.10 and up. To create your own desktop web app, import and set up the WebApp class. @@ -18,30 +18,29 @@ This will create a window with the website, using the icon provided. .. note:: - If your site needs Flash Player, you'll need the appropriate Flash Player plugin installed system-wide. For QtWebKit - you will need the NPAPI plugin, and for QtWebEngine you will need the PPAPI plugin. + If your site needs Flash Player, you'll need the appropriate Flash Player plugin installed system-wide. """ import logging import sys import platform -from PyQt5 import QtCore, QtGui, QtWidgets, QtWebEngineWidgets +from PySide6 import QtCore, QtGui, QtWidgets, QtWebEngineCore, QtWebEngineWidgets SETTINGS = [ - QtWebEngineWidgets.QWebEngineSettings.PluginsEnabled, - QtWebEngineWidgets.QWebEngineSettings.JavascriptCanAccessClipboard, - QtWebEngineWidgets.QWebEngineSettings.LocalContentCanAccessRemoteUrls + QtWebEngineCore.QWebEngineSettings.PluginsEnabled, + QtWebEngineCore.QWebEngineSettings.JavascriptCanAccessClipboard, + QtWebEngineCore.QWebEngineSettings.LocalContentCanAccessRemoteUrls ] LOG_LEVELS = { - QtWebEngineWidgets.QWebEnginePage.InfoMessageLevel: logging.INFO, - QtWebEngineWidgets.QWebEnginePage.WarningMessageLevel: logging.WARNING, - QtWebEngineWidgets.QWebEnginePage.ErrorMessageLevel: logging.ERROR + QtWebEngineCore.QWebEnginePage.InfoMessageLevel: logging.INFO, + QtWebEngineCore.QWebEnginePage.WarningMessageLevel: logging.WARNING, + QtWebEngineCore.QWebEnginePage.ErrorMessageLevel: logging.ERROR } log = logging.getLogger(__name__) -class WebPage(QtWebEngineWidgets.QWebEnginePage): +class WebPage(QtWebEngineCore.QWebEnginePage): """ A custom QWebEnginePage which logs JS console messages to the Python logging system """ @@ -50,7 +49,6 @@ class WebPage(QtWebEngineWidgets.QWebEnginePage): Custom logger to log console messages to the Python logging system """ log.log(LOG_LEVELS[level], f'{source_id}:{line_number} {message}') - print(message) class WebWindow(QtWidgets.QWidget):