Skip to content

Bug introduced in setState in version 0.11.x, 0.12.3 (but it's working on 0.12.0!) #2029

@JeanBilheux

Description

@JeanBilheux

Short description

Prior to version of pyqtgraph 0.11.x, I heavily used the setState property in order to be able to keep the pan and zoom settings the user defined. For example, some of my application have the imageView on top and a slider at the bottom. The user click on the slider to display a different image. But if he pan or zoom into the image, switching to another image keeps the pan and zoom settings. Other applications I wrote modified the image and refresh it, still keeping the pan and zoom settings as shown in this animation.

without_issue

But if I'm using pyqtgraph 0.11.x or later, the view auto-reset. and a single action on the mouse (little pan, little zooming) correctly reset the image view to the range previously defined.

withIssue

I tested the issue with various pyqtgraph version and came up with the following conclusion:
0.10.x -> it's working
0.11.0 -> not working
0.12.0 -> it's working
0.12.3 -> not working

Code to reproduce

Here is some of the code that I use to record the image settings before plotting a new image, and then resetting the
view according to the parameters saved

[...]

 _view = self.parent.ui.image_view.getView()
 _view_box = _view.getViewBox()
 _state = _view_box.getState()

  self.parent.ui.image_view.setImage(_image)
  _view_box.setState(_state)

[...]

Expected behavior

The new plot should have the same view state as the previous plot

Real behavior

The new plot state is reset.

An error occurred?
Post the full traceback inside these 'code fences'!

Tested environment(s)

  • PyQtGraph version: tested with 0.10.x, 0.11.0, 0.12.0, 0.12.3
  • Qt Python binding: PyQt5 5.15.4 Qt 5.15.2
  • Python version: 3.7
  • NumPy version: 1.21.0
  • Operating system: Mac OS, Linux
  • Installation method: Using conda environment for most librairies. Used pip for pyqtgraph.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions