0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

tkinterを使ってmatplotlibによる図を外部表示する

Posted at

tkinterを使って図の外部表示

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()

これで青い羽根マークの図が表示されればok

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?