开发者

tkinter photoimage constructor

开发者 https://www.devze.com 2023-03-19 10:00 出处:网络
I am forced to use the plain PhotoImage class, since I had too many troubles installing PIL on the osx machine I use - I can live with it, resorting to use just GIF files.

I am forced to use the plain PhotoImage class, since I had too many troubles installing PIL on the osx machine I use - I can live with it, resorting to use just GIF files.

Trouble is, there's a place where I really need to create a new image of a given color, size: just a simple colored square. There is some way to do i开发者_JS百科t, à la Image.new('RGB', size, color) ?


from Tkinter import * #from tkinter

root = Tk()
i = PhotoImage(width=100, height=100)
l = Label(root, image=i)
l.pack()
i.put("{red}", to=(4,6,80,80))
root.update()
root.after(3000)
i.put("{blue}", to=(4,6,80,80))
root.mainloop()
0

精彩评论

暂无评论...
验证码 换一张
取 消