()
| 247 | |
| 248 | @_isolated_tk_test(success_count=2) |
| 249 | def test_embedding(): |
| 250 | import tkinter as tk |
| 251 | from matplotlib.backends.backend_tkagg import ( |
| 252 | FigureCanvasTkAgg, NavigationToolbar2Tk) |
| 253 | from matplotlib.backend_bases import key_press_handler |
| 254 | from matplotlib.figure import Figure |
| 255 | |
| 256 | root = tk.Tk() |
| 257 | |
| 258 | def test_figure(master): |
| 259 | fig = Figure() |
| 260 | ax = fig.add_subplot() |
| 261 | ax.plot([1, 2, 3]) |
| 262 | |
| 263 | canvas = FigureCanvasTkAgg(fig, master=master) |
| 264 | canvas.draw() |
| 265 | canvas.mpl_connect("key_press_event", key_press_handler) |
| 266 | canvas.get_tk_widget().pack(expand=True, fill="both") |
| 267 | |
| 268 | toolbar = NavigationToolbar2Tk(canvas, master, pack_toolbar=False) |
| 269 | toolbar.pack(expand=True, fill="x") |
| 270 | |
| 271 | canvas.get_tk_widget().forget() |
| 272 | toolbar.forget() |
| 273 | |
| 274 | test_figure(root) |
| 275 | print("success") |
| 276 | |
| 277 | # Test with a dark button color. Doesn't actually check whether the icon |
| 278 | # color becomes lighter, just that the code doesn't break. |
| 279 | |
| 280 | root.tk_setPalette(background="sky blue", selectColor="midnight blue", |
| 281 | foreground="white") |
| 282 | test_figure(root) |
| 283 | print("success") |
| 284 | |
| 285 | |
| 286 | @_isolated_tk_test(success_count=1) |
nothing calls this directly
no test coverage detected
searching dependent graphs…