I am trying to use Tkinter to create a view, so I also use pylab. My problem is that I get the error message:
AttributeError: the 'module' object does not have the 'Figure' attribute
and the error comes from this line of code:
self.fig = FigureCanvasTkAgg(pylab.figure(), master=self)
I am new to python, so I do not know how to fix this, as it figure()should be part of the pylab library.
Any suggestions on how to fix this would be appreciated.
EDIT
Here is the full code:
from Tkinter import *
import ttk
from ttk import Style
import pylab
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
import matplotlib.pyplot as plt
from numpy import cumsum
import matplotlib
class GUI(Frame):
def __init__(self, parent, motspiller):
Frame.__init__(self, parent)
self.style = Style()
self.fig = None
def setup(self):
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
label = Label(self.parent)
label.place(x=800, y=50)
quit_button = Button(self, text="Quit", command=self.quit)
quit_button.place(x=1000, y=450)
self.fig = FigureCanvasTkAgg(pylab.figure(), master=self)
self.fig.get_tk_widget().grid(column=0, row=0)
self.fig.show()
source
share