0
我想在tkinter應用程序中嵌入一個matplotlib圖,所以第一個地方是example from matplotlib,對吧?在tkinter中嵌入matplotlib - 例子freeze
我使用蟒蛇4.0.5與蟒蛇3.5.1。當我嘗試運行示例代碼時,應用程序凍結。如果我用python.exe運行它,控制檯會凍結,我必須強制關閉它。沒有tkinter窗口出現。
在此代碼:
f = Figure(figsize=(5, 4), dpi=100)
a = f.add_subplot(111)
t = arange(0.0, 3.0, 0.01)
s = sin(2*pi*t)
a.plot(t, s)
# a tk.DrawingArea
canvas = FigureCanvasTkAgg(f, master=root)
canvas.show()
這個問題似乎是與最後一行,canvas.show()。如果我對此發表評論,窗口至少會出現。