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

parameterTree contents are not displayed on the correct position when the parameterTree widget has scroll bars #3003

Open
alberto-gomezcasado-AP opened this issue Apr 24, 2024 · 4 comments
Labels
help wanted Assistance resolving this issue is wanted parameterTree

Comments

@alberto-gomezcasado-AP
Copy link

Short description

I have a parameterTree which may become bigger than the reserved space for the layout. When this happens scroll bars are shown, but part of the UI is displaced / do not scroll together with the rest of the UI

image
Scroll left
image
Scroll down, notice the first column has scrolled up, but the second stays, leading to a mismatch on the presented content
image

Code to reproduce

I stripped down the app to make a minimal example

from pyqtgraph.Qt import QtCore

try:
    from pyqtgraph.Qt.QtWidgets import QApplication, QGraphicsProxyWidget
except ModuleNotFoundError:  # pyqtgraph < 0.13
    from pyqtgraph.Qt import QtWidgets as qwt

    QApplication = qwt.QApplication
    QGraphicsProxyWidget = qwt.QGraphicsProxyWidget

import pyqtgraph as pg
from pyqtgraph.parametertree import Parameter, ParameterTree

plot_params = []
for i in range(10):
    plot_params.append({"name": f"p{i}", "type":"int", "value":i})

parameters = [
    {"name": "Plot", "type": "group", "children": plot_params},
]

class Monitor:

    def __init__(self):
        self._app = QApplication([])

        self.paramtree = ParameterTree(showHeader=False)
        self._p = Parameter.create(
            name="Configuration", type="group", children=parameters
        )
        self.paramtree.setParameters(self._p, showTop=False)

        self.pw = pg.GraphicsView()
        self.pw.setWindowTitle("test")
        self.pw.show()

        self.ly = pg.GraphicsLayout()

        proxy = QGraphicsProxyWidget()
        proxy.setWidget(self.paramtree)
        proxy.setMinimumWidth(250)

        self.pltitem = pg.PlotItem()

        self.ly.addItem(self.pltitem, row=1, col=1)

        self.ly.addItem(proxy, row=1, col=2, rowspan=1, colspan=2)

        self.pw.setCentralWidget(self.ly)
        self.pw.setCentralWidget(self.ly)
        self.pw.resize(1800, 700)


if __name__ == "__main__":
    mon = Monitor()
    QApplication.instance().exec_()

Once launched, simply resize the window until the parameter tree shows a scroll bar, then it is easy to see the second column gets out of place
image

Tested environment(s)

I have reproduced this problem in:

  • PyQtGraph version: 0.13.6 and 0.13.3
  • Qt Python binding: PyQt5 5.15.6 Qt 5.15.2
  • Python version: 3.11.5
  • NumPy version: 1.25.1
  • Operating system: Windows 10 Enterprise

Also in:

  • PyQtGraph version: 0.12.1
  • Qt Python binding: PyQt5 5.15.1 Qt 5.15.1
  • Python version: 3.9.4
  • NumPy version: 1.26.4
  • Operating system: Windows 10 Enterprise
@j9ac9k
Copy link
Member

j9ac9k commented Apr 27, 2024

Can replicate on macOS with Qt6:

image

@j9ac9k
Copy link
Member

j9ac9k commented Apr 27, 2024

I'm going to assume this has something to do w/ the use of the QGraphicsProxyWidget because I can't replicate this behavior anywhere else we use parameter trees with plots, which all our benchmark examples use that setup.

@j9ac9k
Copy link
Member

j9ac9k commented Apr 28, 2024

I tinkered a bunch w/ this and couldn't make headway. I did attempt a non-pyqtgraph example to try and replicate the issue, but that was working as expected. Code in case someone wants to tinker w/ that.

class Monitor:

    def __init__(self):

        self.paramtree = QtWidgets.QTreeWidget()
        self.paramtree.setColumnCount(2)

        items = []
        for row, letter in enumerate(string.ascii_lowercase):
            items.append(QtWidgets.QTreeWidgetItem([letter]))

        self.paramtree.insertTopLevelItems(0, items)

        items = []
        for row, letter in enumerate(string.ascii_uppercase):
            item = QtWidgets.QTreeWidgetItem()
            item.setData(1, 0, letter)
            items.append(item)
            self.paramtree.addTopLevelItem(item)

        proxy = QtWidgets.QGraphicsProxyWidget()
        proxy.setWidget(self.paramtree)
        proxy.setMinimumWidth(250)

        self.graphicsView = QtWidgets.QGraphicsView()
        sceneObj = QtWidgets.QGraphicsScene()
        self.graphicsView.setScene(sceneObj)

        self.plotArea = QtWidgets.QGraphicsWidget()

        self.centralLayout = QtWidgets.QGraphicsGridLayout()
        self.centralLayout.addItem(self.plotArea, 1, 1, 1, 1)
        self.centralLayout.addItem(proxy, 1, 2, 1, 1)

        self.graphicsWidget = QtWidgets.QGraphicsWidget()
        self.graphicsWidget.setLayout(self.centralLayout)
        self.graphicsView.scene().addItem(self.graphicsWidget)
        self.graphicsView.resize(1800, 700)
        self.graphicsView.show()

@j9ac9k j9ac9k added parameterTree help wanted Assistance resolving this issue is wanted labels Apr 28, 2024
@alberto-gomezcasado-AP
Copy link
Author

I'm going to assume this has something to do w/ the use of the QGraphicsProxyWidget because I can't replicate this behavior anywhere else we use parameter trees with plots, which all our benchmark examples use that setup.

I suspected that might be the case. I had to use the proxy because the layout refuses to add the plain parameter tree and I just found that solution. Do you know a way to place the parameter tree widget into layouts without using the QGraphicsProxyWidget?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Assistance resolving this issue is wanted parameterTree
Projects
None yet
Development

No branches or pull requests

2 participants