为什么 Photoimage 放慢? [英] Why is Photoimage put slow?

查看:32
本文介绍了为什么 Photoimage 放慢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在处理照片图像对象时,使用:

When manipulating photoimage objects, with:

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 操作需要很长时间.有没有更快的方法来做到这一点?

the put operation takes a very long time. Is there a faster method of doing this?

推荐答案

使用边界框:

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()

这篇关于为什么 Photoimage 放慢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆