加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python – 为什么Photoimage放慢了?

发布时间:2020-12-16 23:14:25 所属栏目:Python 来源:网络整理
导读:在操作photoimage对象时,使用: import tkinter as tkimg = 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 *
在操作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()

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读