下面的代码是我编写的代码片段,它基本上在 tkinter 窗口中显示了一个图形,但是在添加动画(更新)图形时遇到了困难。以下是我不断收到的错误,任何帮助将不胜感激。
Traceback (most recent call last):
File "C:\Users\nasto\Documents\Company\CMSFRAME.py", line 163, in <module>
ani = animation.FuncAnimation (f, animate, interval=1000)
File "C:\Users\nasto\AppData\Local\Programs\Python\Python36-32\lib\site-packages\matplotlib\animation.py", line 1462, in __init__
TimedAnimation.__init__(self, fig, **kwargs)
File "C:\Users\nasto\AppData\Local\Programs\Python\Python36-32\lib\site-packages\matplotlib\animation.py", line 1225, in __init__
event_source = fig.canvas.new_timer()
AttributeError: 'NoneType' object has no attribute 'new_timer'
Run Code Online (Sandbox Code Playgroud)
我的代码片段:
canvas = FigureCanvasTkAgg(f, self)
canvas.show()
canvas.get_tk_widget().pack(side=tk.LEFT, fill=tk.BOTH, expand = True)
toolbar = NavigationToolbar2TkAgg(canvas, self)
toolbar.update()
canvas._tkcanvas.pack(side=tk.LEFT, fill=tk.BOTH, expand = True)
f = Figure(figsize = (5,5), dpi=100)
a = f.add_subplot(111)
def animate(interval):
pullData = open('financeData.txt','r').read() …Run Code Online (Sandbox Code Playgroud) 我将如何继续将小部件放置在处于缩放状态且在使用时无法调整大小的框架上.grid()?
我希望能够将按钮放在屏幕的最右侧,同时在屏幕的左侧放置一个树状视图,例如在中间有一个“空白”的实例。我不确定是否可以亲自完成,根据我对 tkinter 的经验,我只使用了不是“缩放”或“全屏”的较小窗口,这使得.grid()放置非常容易使用而没有这个问题。我在网上寻找解决方案,但还没有找到。
我希望能够在下面提供的布局中布局我的 tkinter 窗口。
