I\'m working on creating a program that utilizes Tkinter
and matplotlib
. I have 2 lists of lists (one for x-axis, one
The AttributeError: App instance has no attribute 'canvas'
means that your code references the canvas attribute before it has been created/assigned.
This line:
self.button_left = Button(frame,text="< Previous Event",
command=self.decrease(event_num))
is calling the decrease
method because you used parentheses and provided arguments instead of just binding the handler. Inside the decrease method, you're accessing self.canvas
to call the draw method.
That is happening before you create the canvas attribute, which happens on this line:
self.canvas = FigureCanvasTkAgg(fig,master=master)
Make event_num
an attribute of the App
object; then you won't have to pass arguments to the handler when you bind it. You can do this by assigning self.event_num = 1
inside __init__
.