8000 Merge pull request #15268 from meeseeksmachine/auto-backport-of-pr-15… · matplotlib/matplotlib@00996b9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 00996b9

Browse files
authored
Merge pull request #15268 from meeseeksmachine/auto-backport-of-pr-15266-on-v3.2.x
Backport PR #15266 on branch v3.2.x (Embedding in Tk example: Fix toolbar being clipped.)
2 parents 5057024 + af46489 commit 00996b9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

examples/user_interfaces/embedding_in_tk_sgskip.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@
2525

2626
canvas = FigureCanvasTkAgg(fig, master=root) # A tk.DrawingArea.
2727
canvas.draw()
28-
canvas.get_tk_widget().pack(side=tkinter.TOP, fill=tkinter.BOTH, expand=1)
2928

3029
toolbar = NavigationToolbar2Tk(canvas, root)
3130
toolbar.update()
32-
canvas.get_tk_widget().pack(side=tkinter.TOP, fill=tkinter.BOTH, expand=1)
3331

3432

3533
def on_key_press(event):
@@ -40,6 +38,12 @@ def on_key_press(event):
4038
canvas.mpl_connect("key_press_event", on_key_press)
4139

4240
button = tkinter.Button(master=root, text="Quit", command=root.quit)
41+
42+
# Packing order is important. Widgets are processed sequentially and if there
43+
# is no space left, because the window is too small, they are not displayed.
44+
# The canvas is rather flexible in its size, so we pack it last which makes
45+
# sure the UI controls are displayed as long as possible.
4346
button.pack(side=tkinter.BOTTOM)
47+
canvas.get_tk_widget().pack(side=tkinter.TOP, fill=tkinter.BOTH, expand=1)
4448

4549
tkinter.mainloop()

0 commit comments

Comments
 (0)
0