The following code works well in Python 2.7, but gives an error message in Python 3.3 (finished with exit code -1073741819). The error seems to occur in canvas = FigureCanvasTkAgg(self.f, master=self.root) - debugging does not show any additional information. Any suggestions what could be the cause and how to fix it are appreciated.
The original code originates from the below link, which describes how to integrate matplotlib with tkinter: http://matplotlib.org/examples/user_interfaces/embedding_in_tk.html
import tkinter as tk
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
from matplotlib.figure import Figure
import Charts as sp
class GUI(tk.Frame):
def __init__(self, master=None):
self.l=[]
self.active=False
self.root = self.root = tk.Tk()
self.root.title('Test')
self.x=[]; self.y=[]; self.x = range(0, 100)
for each in self.x:
self.y.append(2)
self.f = Figure(figsize=(5,4), dpi=60);
self.a = self.f.add_subplot(111)
self.line1, = self.a.plot(self.x, self.y, 'r-') # Returns a tuple of line objects, thus the comma
self.a.axis((0,100,0,5))
self.a.set_title('Plot Title')
canvas = FigureCanvasTkAgg(self.f, master=self.root)
canvas.show()
if __name__ == '__main__':
gui = GUI()
gui.root.mainloop()
import tkinter; root = tkinter.Tk(); root.mainloop()) I'm guessing that you might somehow have a broken Tkinter install for python3.TkAggbackend? (e.g.import matplotlib; matplotlib.use("TkAgg"); import matplotlib.pyplot as plt; plt.subplots(); plt.show()) How did you install matplotlib?