8000 Only set Tk scaling-on-map for non-Windows systems · matplotlib/matplotlib@7cae31e · GitHub
[go: up one dir, main page]

Skip to content

Commit 7cae31e

Browse files
committed
Only set Tk scaling-on-map for non-Windows systems
On Windows, the DPI that Tk sees is 96 for regular screens and some multiple of that for HiDPI screens. On Linux, the DPI is the true DPI (or at least what the display server tells it is true), and doesn't have anything to do with HiDPI. On macOS, the DPI appears closer to 72 by default.
1 parent 1809c2d commit 7cae31e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/matplotlib/backends/_backend_tk.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ def __init__(self, figure=None, master=None):
175175
master=self._tkcanvas, width=w, height=h)
176176
self._tkcanvas.create_image(w//2, h//2, image=self._tkphoto)
177177
self._tkcanvas.bind("<Configure>", self.resize)
178-
self._tkcanvas.bind("<Map>", self._update_device_pixel_ratio)
178+
if sys.platform == 'win32':
179+
self._tkcanvas.bind("<Map>", self._update_device_pixel_ratio)
179180
self._tkcanvas.bind("<Key>", self.key_press)
180181
self._tkcanvas.bind("<Motion>", self.motion_notify_event)
181182
self._tkcanvas.bind("<Enter>", self.enter_notify_event)
@@ -212,7 +213,7 @@ def filter_destroy(event):
212213
self._rubberband_rect = None
213214

214215
def _update_device_pixel_ratio(self, event=None):
215-
# Tk gives scaling with respect to 72 DPI, but most (all?) screens are
216+
# Tk gives scaling with respect to 72 DPI, but Windows screens are
216217
# scaled vs 96 dpi, and pixel ratio settings are given in whole
217218
# percentages, so round to 2 digits.
218219
ratio = round(self._tkcanvas.tk.call('tk', 'scaling') / (96 / 72), 2)

0 commit comments

Comments
 (0)
2A4D
0