napari: Pyside 5.15.0 breaking buttons?

🐛 Bug

just found that all instances of QtModePushButton weren’t working for me. (like the “add layer” buttons) Screen Shot 2020-05-29 at 11 13 35 AM

I had pyside 5.15.0 in my environment, and downgraded to 5.14.2 and they worked again…

Can someone else confirm this?

If so… we should probably release a patch that pins pyside2 < 5.15

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 31 (26 by maintainers)

Most upvoted comments

nothing figured out yet, just some notes: I tried to create a minimal example of this button problem by ripping out the bare minimum code that gets us from the Viewer down to the QtViewerPushButton in the QtLayerButtons where the “add layer” buttons live… but it still “works” (in the sense that clicking the buttons calls the callback).

minimal example
from qtpy.QtCore import Qt
from qtpy.QtWidgets import (
    QWidget,
    QApplication,
    QPushButton,
    QMainWindow,
    QHBoxLayout,
    QVBoxLayout,
    QFrame,
    QSplitter,
    QDockWidget,
)


class QtViewerPushButton(QPushButton):
    def __init__(self, button_name, slot=None):
        super().__init__(button_name)
        if slot is not None:
            self.clicked.connect(slot)


class QtLayerButtons(QFrame):
    def __init__(self):
        super().__init__()
        self.newPointsButton = QtViewerPushButton("new_points", lambda: print("click"))
        layout = QHBoxLayout()
        layout.addWidget(self.newPointsButton)
        self.setLayout(layout)


class QtViewerDockWidget(QDockWidget):
    def __init__(self, qt_viewer, widget: QWidget, name: str = ""):
        self.qt_viewer = qt_viewer
        super().__init__(name)
        self.qt_area = Qt.LeftDockWidgetArea
        self.setMinimumHeight(50)
        self.setMinimumWidth(50)
        self.setWidget(widget)
        widget.setParent(self)
        self._widget = widget


class QtViewer(QSplitter):
    def __init__(self, viewer):
        super().__init__()

        self.viewer = viewer
        self.layerButtons = QtLayerButtons()
        layerList = QWidget()
        layerListLayout = QVBoxLayout()
        layerListLayout.addWidget(self.layerButtons)
        layerList.setLayout(layerListLayout)
        self.dockLayerList = QtViewerDockWidget(self, layerList, name="layer list")
        self.dockLayerList.setMaximumWidth(258)
        self.dockLayerList.setMinimumWidth(258)


class Window:
    def __init__(self, qt_viewer: QtViewer, *, show: bool = True):
        self.qt_viewer = qt_viewer
        self._qt_window = QMainWindow()
        self._qt_center = QWidget(self._qt_window)
        self._qt_center.setLayout(QHBoxLayout())
        self._qt_center.layout().addWidget(self.qt_viewer)
        self._qt_center.layout().addWidget(
            QtViewerPushButton("asdf", slot=lambda: print("click"))
        )
        self._qt_window.setCentralWidget(self._qt_center)
        self._qt_window.setFixedSize(500, 300)
        self._add_viewer_dock_widget(self.qt_viewer.dockLayerList)

        if show:
            self._qt_window.resize(self._qt_window.layout().sizeHint())
            self._qt_window.show()

    def _add_viewer_dock_widget(self, dock_widget: QtViewerDockWidget):
        """Add a QtViewerDockWidget to the main window

        Parameters
        ----------
        dock_widget : QtViewerDockWidget
            `dock_widget` will be added to the main window.
        """
        dock_widget.setParent(self._qt_window)
        self._qt_window.addDockWidget(dock_widget.qt_area, dock_widget)


class Viewer:
    def __init__(self):
        qt_viewer = QtViewer(self)
        self.window = Window(qt_viewer, show=True)


app = QApplication([])
v = Viewer()
app.exec_()

I don’t think the qsocketnotifyer fix in 5.15.1 is going to help us with buttons here. Since I can’t reproduce the bug with a minimal example (above) I think the button thing is a more complicated napari-specific problem

I’m not sure if it is connected with this Issue but Qt 5.15 remove xcb libs form build so it fail to run QApplication because of problem with loading plug-in:

https://codereview.qt-project.org/c/qt/qtbase/+/253905

I need to run install

libdbus-1-3 libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0

on ubuntu to get test not fail with sigabort (on github actions and Azure pipelines).

I’d go <, much easier to intentionally fix and release when we want then have to go through another emergency release if it breaks again

Rename issue “PySide2 5.15 breaking the world”?