8000 remove _master attribute from FigureCanvasTk · matplotlib/matplotlib@fdc0793 · GitHub
[go: up one dir, main page]

Skip to content

Commit fdc0793

Browse files
remove _master attribute from FigureCanvasTk
The nominal parent widget of FigureCanvasTk can sometimes have a call method and sometimes not, occasionally breaking _update_device_pixel_ratio. It has complete control over what _tkcanvas is, and _tkcanvas can substitute for all uses of _master.
1 parent 3a265b3 commit fdc0793

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/matplotlib/backends/_backend_tk.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,13 @@ def filter_destroy(event):
209209
self.close_event()
210210
root.bind("<Destroy>", filter_destroy, "+")
211211

212-
self._master = master
213212
self._tkcanvas.focus_set()
214213

215214
def _update_device_pixel_ratio(self, event=None):
216215
# Tk gives scaling with respect to 72 DPI, but most (all?) screens are
217216
# scaled vs 96 dpi, and pixel ratio settings are given in whole
218217
# percentages, so round to 2 digits.
219-
ratio = round(self._master.call('tk', 'scaling') / (96 / 72), 2)
218+
ratio = round(self._tkcanvas.tk.call('tk', 'scaling') / (96 / 72), 2)
220219
if self._set_device_pixel_ratio(ratio):
221220
# The easiest way to resize the canvas is to resize the canvas
222221
# widget itself, since we implement all the logic for resizing the
@@ -367,7 +366,7 @@ def new_timer(self, *args, **kwargs):
367366

368367
def flush_events(self):
369368
# docstring inherited
370-
self._master.update()
369+
self._tkcanvas.update()
371370

372371
def start_event_loop(self, timeout=0):
373372
# docstring inherited
@@ -379,14 +378,14 @@ def start_event_loop(self, timeout=0):
379378
else:
380379
self._event_loop_id = self._tkcanvas.after_idle(
381380
self.stop_event_loop)
382-
self._master.mainloop()
381+
self._tkcanvas.mainloop()
383382

384383
def stop_event_loop(self):
385384
# docstring inherited
386385
if self._event_loop_id:
387-
self._master.after_cancel(self._event_loop_id)
386+
self._tkcanvas.after_cancel(self._event_loop_id)
388387
self._event_loop_id = None
389-
self._master.quit()
388+
self._tkcanvas.quit()
390389

391390

392391
class FigureManagerTk(FigureManagerBase):

0 commit comments

Comments
 (0)
0