【发布时间】:2022-08-20 10:49:54
【问题描述】:
我想要的是:
我想要一个具有快速显示*生成的动画小部件(延迟,允许小于 20 秒)并具有运行像素变化动画的特殊功能无延迟(延迟,允许小于 20 毫秒)在 Python 3 中。
错误的方法:
最简单的方法是像素面板。但它的生成速度非常缓慢**。 这是它的代码:
import tkinter as t
tk = t.Tk()
n = 1100
k = 900 # Display sizes
canvas = t.Canvas(tk, width =k, height = n)
canvas.grid(column = 0, row = 0)
ids = [] # Pixel identifiers
for i in range(n):
id2 = []
for j in range(k):
id2.append(cv.create_rectangle(i,j,i+1,j+1,outline = \"black\"))
ids.append(id2)
def animation(animation_list): # Animation function,animation_list - list of coords and colors tuples(as example,[(1, 0, \"red\"), (2, 1, \"green\")].
global canvas
for x, y, color in animation_list:
canvas.itemconfig(ids[x][y],outline = color)
* 尺寸为 1100x900(990k 像素)
** Debug 显示 22 秒,但花了超过一分钟,而且窗口滞后。
标签: python python-3.x tkinter animation graphics