MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_canvas_focus

Function test_canvas_focus

lib/matplotlib/tests/test_backend_tk.py:220–245  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

218
219@_isolated_tk_test(success_count=1)
220def test_canvas_focus():
221 import tkinter as tk
222 import matplotlib.pyplot as plt
223 success = []
224
225 def check_focus():
226 tkcanvas = fig.canvas.get_tk_widget()
227 # Give the plot window time to appear
228 if not tkcanvas.winfo_viewable():
229 tkcanvas.wait_visibility()
230 # Make sure the canvas has the focus, so that it's able to receive
231 # keyboard events.
232 if tkcanvas.focus_lastfor() == tkcanvas:
233 success.append(True)
234 plt.close()
235 root.destroy()
236
237 root = tk.Tk()
238 fig = plt.figure()
239 plt.plot([1, 2, 3])
240 root.after(0, plt.show)
241 root.after(100, check_focus)
242 root.mainloop()
243
244 if success:
245 print("success")
246
247
248@_isolated_tk_test(success_count=2)

Callers

nothing calls this directly

Calls 3

figureMethod · 0.80
mainloopMethod · 0.80
plotMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…