from PIL import Image as Imag
from PIL import ImageTk
from random import randint
im = Imag.new("RGB", (500, 500))
pix = im.load()
for i in range(500):
for j in range(500):
pix[i, j] = randint(0, 255), randint(0, 255), randint(0, 255)
im.save('res.jpg')
from tkinter import *
root = Tk()
root.geometry('600x600')
canvas = Canvas(root, width=500, height=500)
canvas.pack()
pilImage = Imag.open("res.jpg")
image = ImageTk.PhotoImage(pilImage)
imagesprite = canvas.create_image(0, 0, image=image)
root.mainloop()
Comments
Leave a comment