As an alternative to the approach in my previous message,  Qt5 also has a 
QtWebEngineWidgets module.  It isn't used by current code because QWebView 
is actually a QWebEngineView under the covers.  But we could add importing  
QtWebEngineWidgets for Qt5 as well as Qt6. Then leo.core.leoQt could return 
either the Qt5 or Qt6 version of QWebEngineView, no version tests 
required.  QWebView could be aliased to this QWebEngineView for use by 
existing code.

IMHO, this would be a better approach.  There will still be the problem 
that some of the Qt6 WebEngineView's enums have a different classpath, but 
we've dealt with that for other Qt classes already.

At any rate, any one of these three approaches gets VR3 and Freewin working 
again.  Hurray!

On Monday, February 14, 2022 at 11:55:42 AM UTC-5 tbp1...@gmail.com wrote:

> 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/60e62f44-91d1-4d78-8a20-0a9c417863a0n%40googlegroups.com.

Reply via email to