alessandro
alessandro

Reputation: 3984

tkinter photoimage constructor

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 it, à la Image.new('RGB', size, color) ?

Upvotes: 3

Views: 788

Answers (1)

noob oddy
noob oddy

Reputation: 1339

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

Upvotes: 4

Related Questions