pywwt icon indicating copy to clipboard operation
pywwt copied to clipboard

Compatibility issue with PyQt6

Open astrofrog opened this issue 3 years ago • 2 comments

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.

astrofrog avatar Jan 12 '23 11:01 astrofrog

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.

pkgw avatar Jan 12 '23 14:01 pkgw

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)

Carifio24 avatar Jan 12 '23 15:01 Carifio24