Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # tk_putpixel.py
- from tkinter import *
- from PIL import Image, ImageTk
- ww = 200
- hh = 200
- b = 128
- pixels = tuple([(r,g,b) for r in range(ww) for g in range(hh)])
- root = Tk()
- canvas = Canvas(root, width=ww, height=hh, background="black")
- canvas.pack()
- img = Image.new('RGB', (ww, hh))
- img.putdata(pixels)
- tk_img = ImageTk.PhotoImage(img)
- canvas.create_image(0, 0, anchor=NW, image=tk_img)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement