Skip to content

Conversation

@rgcarrasqueira
Copy link

Hi!

I've made some adjustments to support Qt5.9

@ghost
Copy link

ghost commented Jul 24, 2017

This fails if both PyQt4 and PyQt4 are available bu only PyQt5.QtWebEngineWidgets is unavailable (I guess it's only available in 5.9?):

> python
Python 2.7.13 (default, Mar 22 2017, 12:31:17) [GCC] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from PyQt5.QtCore import *
>>> from PyQt4.QtCore import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: the PyQt4.QtCore and PyQt5.QtCore modules both wrap the QObject class

@Cybso
Copy link
Collaborator

Cybso commented Jul 24, 2017

Additionally, QtWebKit is available for PyQt5, too (however, I don't know if it has been marked as deprecated). I would suggest to use find_spec from importlib to validate the dependencies instead of try..except:

if importlib.util.find_spec("PyQt5") is None:
    import PyQt4...
else:
    import PyQt5...
    if importlib.util.find_spec("PyQt5.QtWebEngineWidgets") is None:
        import PyQt5.QtWebKit
    else:
        import PyQt5.QtWebEngine

(Edit: Sorry, using find_spec would break Python 2.x support)

@rgcarrasqueira
Copy link
Author

Yeah! The Problem is the qt developer changed a lot of things on calling some libraries and methods, for example WebPage was changed to WebPageEngine and it messed up everything.

@Cybso
Copy link
Collaborator

Cybso commented Jul 24, 2017

The easiest solution would be to move the import of QtWebEngine into the first line and only support QtWebKit for Qt4 and QtWebEngine for Qt5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants