Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f208cd3

Browse files
committed
Embedding in Tk example: be more layout manager agnostic.
1 parent 214790d commit f208cd3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
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, expand=1)
4749
canvas.get_tk_widget().pack(side=tkinter.TOP, fill=tkinter.BOTH, expand=1)
4850

4951
tkinter.mainloop()

0 commit comments

Comments
 (0)