Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility issue with PyQt6 #343

Open
astrofrog opened this issue Jan 12, 2023 · 2 comments
Open

Compatibility issue with PyQt6 #343

astrofrog opened this issue Jan 12, 2023 · 2 comments

Comments

@astrofrog
Copy link
Member

If I try and run PyWWT with PyQt6 I run into the following issue:

  File "/Users/tom/python/dev/lib/python3.10/site-packages/pywwt/qt.py", line 153, in __init__
    self.page.setView(self.web)
AttributeError: 'WWTQWebEnginePage' object has no attribute 'setView'

I haven't had a chance yet to investigate what the new API should be for this.

@pkgw
Copy link
Contributor

pkgw commented Jan 12, 2023

Here's someone's analysis of the API changes with some further links. It looks like it's not that setView() has been simply renamed or something ... that API is just gone, which implies to me that one needs to take a new approach to accomplish what the code is doing.

@Carifio24
Copy link
Member

There's a new Qt6 constructor for QWebEngineView that accepts a QWebEnginePage as a parameter. So maybe passing that as an argument, rather than using setView, is what we want?

As a very rough test, using PyQt6 I was able to open a WWT client by tweaking the WWTQtWidget constructor to use some version-conditional logic:

def __init__(self, url, parent=None):
    super(WWTQtWidget, self).__init__(parent=parent)

    
    self.page = WWTQWebEnginePage()
    if PYQT6 or PYSIDE6:
        self.web = WWTWebEngineView(self.page)
    else:
        self.web = WWTWebEngineView()
        self.page.setView(self.web)
        self.web.setPage(self.page)
    self.web.setUrl(QtCore.QUrl(url))

    layout = QtWidgets.QVBoxLayout()
    layout.setContentsMargins(0, 0, 0, 0)
    self.setLayout(layout)
    layout.addWidget(self.web)

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

No branches or pull requests

3 participants