[PYTHON] External display of matplotlib diagrams using tkinter

External display of figures using tkinter

Add the following part under the script that displays the figure with matplotlib.

tkinter.py


def _destroyWindow():
    root.quit()
    root.destroy()
    
root = tk.Tk()
root.withdraw()
root.title("title")
root.geometry("770x500") 
root.protocol('WM_DELETE_WINDOW', _destroyWindow)  # When you close the tkinter window.

# Canvas
canvas = FigureCanvasTkAgg(fig, master=root)  # Generate canvas instance, Embedding fig in root
canvas.draw()
canvas.get_tk_widget().pack()
#canvas._tkcanvas.pack()

# root
root.update()
root.deiconify()
root.mainloop()

If the figure of the blue feather mark is displayed with this, it is ok

Recommended Posts

External display of matplotlib diagrams using tkinter
Japanese display of matplotlib, seaborn
[Python] Extension using inheritance of matplotlib (NavigationToolbar2TK)
Flexible animation creation using animation.FuncAnimation of matplotlib
Display matplotlib diagrams in a web application
Try using Tkinter
Try using matplotlib
Basics of I / O screen using tkinter in python3
Graph drawing using matplotlib
I tried using matplotlib
Using Python #external packages
Try using Python's Tkinter
Example of using lambda
Display of fractions (list)
Installation of matplotlib (Python 3.3.2)
Instantly create a diagram of 2D data using python's matplotlib