8000 Embedding in Tk example: be more layout manager agnostic. · matplotlib/matplotlib@9737747 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9737747

Browse files
committed
Embedding in Tk example: be more layout manager agnostic.
1 parent 7362573 commit 9737747

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

examples/user_interfaces/embedding_in_tk_sgskip.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
canvas = FigureCanvasTkAgg(fig, master=root) # A tk.DrawingArea.
2727
canvas.draw()
2828

29-
toolbar = NavigationToolbar2Tk(canvas, root)
29+
# pack_toolbar=False will make it easier to use a layout manager later on.
30+
toolbar = NavigationToolbar2Tk(canvas, root, pack_toolbar=False)
3031
toolbar.update()
3132

3233

@@ -44,6 +45,7 @@ def on_key_press(event):
4445
# The canvas is rather flexible in its size, so we pack it last which makes
4546
# sure the UI controls are displayed as long as possible.
4647
button.pack(side=tkinter.BOTTOM)
48+
toolbar.pack(side=tkinter.BOTTOM, fill=tkinter.X)
4749
canvas.get_tk_widget().pack(side=tkinter.TOP, fill=tkinter.BOTH, expand=1)
4850

4951
tkinter.mainloop()

lib/matplotlib/backends/_backend_tk.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,9 @@ class NavigationToolbar2Tk(NavigationToolbar2, tk.Frame):
512512
The tk.Window which owns this toolbar.
513513
pack_toolbar : bool, default: True
514514
If True, add the toolbar to the parent's pack manager's packing list
515-
during initialization with *side='bottom'* and *fill='x'*.
515+
during initialization with ``side='bottom'`` and ``fill='x'``.
516516
If you want to use the toolbar with a different layout manager, use
517-
*pack_toolbar=False*.
517+
``pack_toolbar=False``.
518518
"""
519519
def __init__(self, canvas, window, *, pack_toolbar=True):
520520
self.canvas = canvas

0 commit comments

Comments
 (0)
0