So I have the following code:
class GooglePage(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
label = tk.Label(self, text="Google (GOOG)", font=LARGEFONT)
label.pack(pady=10,padx=10)
button1 = ttk.Button(self, text="Back to Home",
command=lambda: controller.show_frame(StartPage))
button1.pack()
f = Figure(figsize=(5,5), dpi=100)
a = f.add_subplot(111)
a.plot(x, y)
canvas = FigureCanvasTkAgg(f, self)
canvas.draw()
canvas.get_tk_widget().pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)
toolbar = NavigationToolbar2Tk(canvas, self)
toolbar.update()
canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True)
So later on in the script, I define x
and y
to be lists that get 1 more element per second. However, a
does not update. I need to know how to get a
to update with x and y.
The first thing I tried was to use a while True loop inside the init function. It didn't run anything after the class declaration of GooglePage
, including more class declarations and important stuff. I also tried to update a
outside the class declaration, when I updated the lists. However, a
, GooglePage.a
, and GooglePage.__init__.a
all throw errors.