File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 2525
2626canvas = FigureCanvasTkAgg (fig , master = root ) # A tk.DrawingArea.
2727canvas .draw ()
28- canvas .get_tk_widget ().pack (side = tkinter .TOP , fill = tkinter .BOTH , expand = 1 )
2928
3029toolbar = NavigationToolbar2Tk (canvas , root )
3130toolbar .update ()
32- canvas .get_tk_widget ().pack (side = tkinter .TOP , fill = tkinter .BOTH , expand = 1 )
3331
3432
3533def on_key_press (event ):
@@ -40,6 +38,12 @@ def on_key_press(event):
4038canvas .mpl_connect ("key_press_event" , on_key_press )
4139
4240button = 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.
4346button .pack (side = tkinter .BOTTOM )
47+ canvas .get_tk_widget ().pack (side = tkinter .TOP , fill = tkinter .BOTH , expand = 1 )
4448
4549tkinter .mainloop ()
You can’t perform that action at this time.
0 commit comments