gpt4 book ai didi

python - 为什么 Photoimage put() 很慢?

转载 作者:太空狗 更新时间:2023-10-29 22:23:25 26 4
gpt4 key购买 nike

当操作 PhotoImage 对象时:

import tkinter as tk

img = tk.PhotoImage(file="myFile.gif")
for x in range(0,1000):
for y in range(0,1000):
img.put("{red}", (x, y))

put 操作需要很长时间。有更快的方法吗?

最佳答案

使用边界框:

from Tkinter import *
root = Tk()
label = Label(root)
label.pack()
img = PhotoImage(width=300,height=300)
data = ("{red red red red blue blue blue blue}")
img.put(data, to=(20,20,280,280))
label.config(image=img)
root.mainloop()

关于python - 为什么 Photoimage put() 很慢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10417524/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com