Answer to Question #111563 in Python for Daniel

Question #111563
Create a code that plots 1000 random points each with their own random color on a user interface
1
Expert's answer
2020-04-24T13:38:26-0400
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()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS