Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Backport PR #30399 on branch v3.10.x (Qt: Fix HiDPI handling on X11/Windows)#30428

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletionslib/matplotlib/backends/backend_qt.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -273,6 +273,7 @@ def showEvent(self, event):
window = self.window().windowHandle()
current_version = tuple(int(x) for x in QtCore.qVersion().split('.', 2)[:2])
if current_version >= (6, 6):
self._update_pixel_ratio()
window.installEventFilter(self)
else:
window.screenChanged.connect(self._update_screen)
Expand Down
61 changes: 23 additions & 38 deletionslib/matplotlib/tests/test_backend_qt.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -175,45 +175,30 @@ def set_device_pixel_ratio(ratio):
assert qt_canvas.device_pixel_ratio == ratio

qt_canvas.manager.show()
qt_canvas.draw()
qt_canvas.flush_events()
size = qt_canvas.size()
set_device_pixel_ratio(3)

# The DPI and the renderer width/height change
assert fig.dpi == 360
assert qt_canvas.renderer.width == 1800
assert qt_canvas.renderer.height == 720

# The actual widget size and figure logical size don't change.
assert size.width() == 600
assert size.height() == 240
assert qt_canvas.get_width_height() == (600, 240)
assert (fig.get_size_inches() == (5, 2)).all()

set_device_pixel_ratio(2)

# The DPI and the renderer width/height change
assert fig.dpi == 240
assert qt_canvas.renderer.width == 1200
assert qt_canvas.renderer.height == 480

# The actual widget size and figure logical size don't change.
assert size.width() == 600
assert size.height() == 240
assert qt_canvas.get_width_height() == (600, 240)
assert (fig.get_size_inches() == (5, 2)).all()

set_device_pixel_ratio(1.5)

# The DPI and the renderer width/height change
assert fig.dpi == 180
assert qt_canvas.renderer.width == 900
assert qt_canvas.renderer.height == 360

# The actual widget size and figure logical size don't change.
assert size.width() == 600
assert size.height() == 240
assert qt_canvas.get_width_height() == (600, 240)
assert (fig.get_size_inches() == (5, 2)).all()

options = [
(None, 360, 1800, 720), # Use ratio at startup time.
(3, 360, 1800, 720), # Change to same ratio.
(2, 240, 1200, 480), # Change to different ratio.
(1.5, 180, 900, 360), # Fractional ratio.
]
for ratio, dpi, width, height in options:
if ratio is not None:
set_device_pixel_ratio(ratio)

# The DPI and the renderer width/height change
assert fig.dpi == dpi
assert qt_canvas.renderer.width == width
assert qt_canvas.renderer.height == height

# The actual widget size and figure logical size don't change.
assert size.width() == 600
assert size.height() == 240
assert qt_canvas.get_width_height() == (600, 240)
assert (fig.get_size_inches() == (5, 2)).all()


@pytest.mark.backend('QtAgg', skip_on_importerror=True)
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp