Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TRUE = 1
- FALSE = 0
- root=tk.Tk()
- kimage_width = 512
- kimage_height = 512
- kimgSize = (kimage_width,kimage_height)
- # Make a color 256K pixel photo of 'stuff', in bytes
- # The image data is in RGBX order
- ColorImage=b''
- for i in range (0,int(kimage_width * kimage_height/8)):
- ColorImage+=bytes([(i>>2) & 0xFF]) # Red
- ColorImage+=bytes([(i>>7) & 0xFF]) # Green
- ColorImage+=bytes([(i>>6) & 0xFF]) # Blue
- ColorImage+=bytes([(i>>0) & 0xFF]) # Not used
- # copy it 8 times
- ColorImage+=ColorImage+ColorImage+ColorImage # 4
- ColorImage+=ColorImage # total = 8 copies
- # make a PIL image?
- kimage = Image.frombytes('RGBX', kimgSize, ColorImage, 'raw')
- kimage.show() # Display image
- #######photo = base64.b64encode(ColorImage) # Crash - makes a zombie
- b=tk.Button(root,justify = tk.LEFT)
- b.config(image=kimage, width="512", height="512")
- b.pack(side=tk.LEFT)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement