Skip to content
Advertisement

Embedding Matplotlib plot inside Tkinter Label

I just put together this basic retirement savings calculator using python. While this works, I had a couple of questions:

  1. Is there a way to embed the plot directly, i.e. without saving it as a PNG and then loading it again?
  2. Line 30 reads img.image = render. While I understand that this updates the image attribute for the label defined on line 29, I am confused why this line is required, since we already call out image = render on line 29 itself. Why twice?
JavaScript

Advertisement

Answer

You can try saving to a stream using BytesIO:

JavaScript

Reference: Why do my Tkinter images not appear?

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement