[Python][Voice]Integrate a plot of matplotlib into tkinter GUI/整合matplotlib的繪圖到 tkinter圖形視窗中
This example shows how to integrate a plot or figure on matplotlib into the graphic user interface of tkinter. 1. Import tkinter 2. Import matplotlib 3. Import FigureCanvasTkAgg 4. Import Figure 5. Build a window named "win". 6. Window format 1: title() 7. Window format 2: geometry() determine size and initial position(x,y) 8. Window format 3: maxsize() set max size of a window 9. Build a figure with figsize = (Width: inch, Length: inch) and dpi = pixel per inch 10. Add the subplot to the figure. 11. Generate x array 12. Generate y array 13. Use plot() to draw the graph 14. Use FigureCanvasTkAgg(figure,win) to put figure on the win (window) 15. Use get_tk_widget().pack() to place figure on the win (window) 16. Build close_win function to end the window 17. Build Button component and give a string to text, and use command to call the function 18. Use pack to arrange Button on bottom side 19. Use mainloop() to keep window running for monitoring and handling events 這個範例說明如...