I' m new to MPL...and rather new to Python...
so I hope I wont say too much stupidities...
I' m writing a little Fileviewer...that will plot the data of the
file...depending on some user inputs (not implemented yet)
so I started playing around...using the Tk embbeded plot exemple...
I added a "Plot" button in particular...that will plot the figure each time
it is pressed...
The program is working as expected...except memory wise...the program keeps
each time plot is pressed it's growing...I believe it's due to some poor
programming on my side, but I can't really put my finger on it right now. I
suspect that I have 2 competing mainloop maybe but i' m not really sure
If you guys could help me...
here's the source:
from Tkinter import *
from numpy import arange, sin, pi
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg,
from matplotlib.figure import Figure
"""class for the SegD viewer"""
self.already_plotted = False
self.iter = 0
self.root = Tk()
self.root.title("Viewer a la con")
"""places the buttons on the window"""
Button(self.root, text = "Open" , width = 9, command =
self.openchoose ).pack( side = TOP )
Button(self.root, text = "Plot" , width = 9, command =
Button(self.root, text = "Quit" , width = 9, command =
self.root.quit ).pack( side = BOTTOM)
"""open a file chooser"""
self.myFrame = Frame(self.root, bg = 'Dark grey', height = 4*100,
width = 10*100)
self.myFrame.pack( side = RIGHT )
print "there was nothing to destroy"
#self.myCanvas = Canvas(self.myFrame, bg = 'Dark grey', height =
4*100, width = 10*100)
self.f = Figure(figsize=(10,4), dpi=100)
a = self.f.add_subplot(111)
t = arange(0.0,5.0,0.1)
s = sin(self.iter*pi*t)
#a.set_xlabel('X axis label')
self.mycanvas = FigureCanvasTkAgg(self.f, master = self.myFrame)
self.mycanvas._tkcanvas.pack(side=TOP, fill=BOTH, expand=1)
# a tk.DrawingArea
self.iter = self.iter + 1
application = SegDviewer()
View this message in context: http://www.nabble.com/Correct-usage-of-Mpl-backend…-tp21012938p21012938.html
Sent from the matplotlib - users mailing list archive at Nabble.com.