Skip to content

ValueError when trying to plot 2D histogram items with PyQt6 #34

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

Closed
michael-miftek opened this issue Feb 21, 2025 · 2 comments
Closed

Comments

@michael-miftek
Copy link

In {plotpy_dir}\items\image\base.py Line 604 - 606 part of BaseImageItem.draw_image()

dest = _scale_rect(
            self.data, src_rect, self._offscreen, dst_rect, self.lut, self.interpolate
        )

There is an issue when using the 2d histogram example that produces the following error.

File "C:\Users\Username\AppData\Local\Programs\Python\Python312\Lib\site-packages\plotpy\items\image\base.py", line 604, in draw_image
    dest = _scale_rect(
           ^^^^^^^^^^^^
ValueError: Error calling Python override of QFrame::paintEvent(): Invalid destination rectangle (expected tuple of 4 integers)

This Error ends up leaving the painter object open causing a crash, after finding the location changing the dst_rect -> tuple(map(int, dst_rect)) fixes the problem but wanted to make someone aware since it is expected as tuple[float, float, float, float].

@PierreRaybaut
Copy link
Contributor

Thanks for the feedback.

I can't reproduce the issue.

Here's how I tried to reproduce this issue:

  • Latest PlotPy version (2.7.2)
  • Windows 11
  • Python 3.12 with the latest versions of all dependencies (see output of pip list: pip_list_py312.txt)
  • Running the plotpy\tests\items\test_hist2d.py test

With all this, there is no exception.

Could you please tell us more about the PlotPy version you are using and your Python distribution (output of a pip list)?

@PierreRaybaut
Copy link
Contributor

I've just managed to reproduce the issue with PyQt6 (instead of PyQt5 in my initial distribution).

@PierreRaybaut PierreRaybaut changed the title Issue with typing for _scale_rect() using floats but expecting ints ValueError when trying to plot 2D histogram items with PyQt6 Feb 23, 2025
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

2 participants