I have succeeded with a slightly different approach:

1.  In LeoQt6.py:

# Must import this before creating the GUI
try:
    from PyQt6 import QtWebEngineWidgets
except ImportError:
    print('No QtWebEngineWidgetsInstall with python3 -m pip install 
--upgrade ')

2.  Add a new try: block to existing VR3 code:

QWebView = None
if isQt6:
    try:
        from leo.core.leoQt6 import QtWebEngineWidgets
        QWebView = QtWebEngineWidgets.QWebEngineView
    except ImportError:
        if not g.unitTesting:
            g.trace("Can't import Qt6 QtWebEngineWidgets")
    except AttributeError:
        if not g.unitTesting:
            g.trace('No QWebView')
    except Exception as e:
        g.trace(e)
else:
    try:
        from leo.core.leoQt import QtWebKitWidgets
        QWebView = QtWebKitWidgets.QWebView
    except ImportError:
        if not g.unitTesting:
            g.trace("Can't import QtWebKitWidgets")
    except AttributeError:
        if not g.unitTesting:
            g.trace('No QWebView')
    except Exception as e:
        g.trace(e)

This gets VR3 to render as intended.  However, I'd like to see something in 
leoQt that makes it unnecessary to test for Qt6, but only for 
QtWebEngineWidgets. See next message for more on this.
On Monday, February 14, 2022 at 11:29:40 AM UTC-5 Edward K. Ream wrote:

> On Monday, February 14, 2022 at 9:59:39 AM UTC-6 Edward K. Ream wrote:
>
> > I have just created #2415 
> <https://github.com/leo-editor/leo-editor/issues/2415> for this. The mind 
> boggles.
>
> PR #2416 <https://github.com/leo-editor/leo-editor/pull/2416> (the 
> ekr-web-engine branch) suggests the way forward.  At startup, *for PyQt6 
> only*, LeoApp.createQtGui imports QtWebEngineWidgets as follows:
>
> from PyQt6 import QtWebEngineWidgets as qt6_QtWebEngineWidgets
> self.qt6_QtWebEngineWidgets = qt6_QtWebEngineWidgets
>
>  So instead of trying to import QtWebEngineWidgets, VR3 could just test 
> and use g.app.qt6_QtWebEngineWidgets.
>
> Does this work for you?
>
> Edward
>

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/c720843a-8fde-414f-948f-a816944c5e31n%40googlegroups.com.

Reply via email to