Simplified question: For some reason the plot isn't updating when I hit my generate plots button.
global f
master = Tk()
plotFrame = Frame(master)
plotFrame.pack(side=TOP)
f = Figure()
canvas = FigureCanvasTkAgg(f, plotFrame)
canvas.get_tk_widget().pack()
toolbar = NavigationToolbar2TkAgg(canvas,master)
toolbar.pack(side=BOTTOM)
def grph():
graph1 = f.add_subplot(111)开发者_Go百科
graph1.plot([1,2,3])
genButton = Button(master, text="Generate plots...", command=grph)
genButton.pack(side=LEFT,anchor=W)
master.mainloop()
Add this line:
def grph():
graph1 = f.add_subplot(111)
graph1.plot([1,2,3])
canvas.draw()
精彩评论