Skip to content

Commit 65cabc9

Browse files
committed
update docstring
1 parent d61cf1a commit 65cabc9

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

lib/matplotlib/backends/_backend_tk.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -270,24 +270,22 @@ def _update_device_pixel_ratio(self, event=None):
270270
elif sys.platform == "linux":
271271
ratio = self._tkcanvas.winfo_fpixels('1i') / 96
272272
if ratio is not None and self._set_device_pixel_ratio(ratio):
273-
# The easiest way to resize the canvas is to emit a
274-
# resize event since we implement all the logic for resizing
275-
# the canvas backing store on that event.
276-
w, h = self.get_width_height(physical=True)
277-
self._tkcanvas.configure(width=w, height=h)
278-
# Use the current actual widget size to recalculate
279-
# figure.size_inches with the new DPI. When the canvas is
280-
# constrained by a geometry manager (pack/grid), <Configure>
273+
# Resize the canvas widget, then explicitly update the figure
274+
# size to match the actual widget dimensions. When the canvas
275+
# is constrained by a geometry manager (pack/grid), <Configure>
281276
# may not fire after configure(), so we handle the resize
282277
# directly — similar to Qt's _update_pixel_ratio approach.
283-
self._resize_canvas(
278+
w, h = self.get_width_height(physical=True)
279+
self._tkcanvas.configure(width=w, height=h)
280+
self._resize_figure_for_canvas_size(
284281
self._tkcanvas.winfo_width(),
285282
self._tkcanvas.winfo_height())
286283

287284
def resize(self, event):
288-
self._resize_canvas(event.width, event.height)
285+
self._resize_figure_for_canvas_size(event.width, event.height)
289286

290-
def _resize_canvas(self, width, height):
287+
def _resize_figure_for_canvas_size(self, width, height):
288+
"""Update figure size and redraw based on a given canvas size."""
291289
if width <= 0 or height <= 0:
292290
return
293291

0 commit comments

Comments
 (0)