ok well I got it to work. It was intended as a screen saver but there are a few things I'd need to tackle before that would work.
from Tkinter import *
from PIL import Image
import ImageTk,sys,random,ImageGrab
img=ImageGrab.grab()#get a screenshot
img.save("screenshot.bmp")
allowed = {}
def Pixel(photo,x,y):#pick out a 50x50 box of pixels
Xstart,Ystart = random.choice(allowed["locations"])
allowed["locations"].remove((Xstart,Ystart))
Xstart,Ystart = Xstart*50,Ystart*50
return Xstart,Ystart
def Start(canvas,frame):#runs the whole program
photo = Image.open("screenshot.bmp")
X,Y = photo.size
Xstart,Ystart = Pixel(photo,X,Y)
NewBlock = photo.crop([Xstart,Ystart,Xstart+50,Ystart+50])
canvas.create_rectangle(Xstart,Ystart, Xstart+49,Ystart+49, fill="black")
tkpi2 = ImageTk.PhotoImage(NewBlock)
canvas.create_image(Xstart, Ystart, image=tkpi2, anchor=NW)
canvas.image.append(tkpi2)
canvas.after(1000,lambda:Fall(canvas,canvas.find_all()[-1],Y,frame))
if allowed["locations"] == []:
canvas = reset(frame)
def Fall(canvas,item,Y,frame):#makes a piece fall
canvas.move(item,0,2)
if canvas.coords(item)[1] < Y:
canvas.after(10,lambda:Fall(canvas,item,Y,frame))
else:
canvas.delete(item)
Start(canvas,frame)
def reset(frame):
canvas = Canvas(frame, width = root.winfo_screenwidth(), height = root.winfo_screenheight(), bg = "blue")
canvas.pack()
photo = Image.open("screenshot.bmp")
X,Y = photo.size
tkpi = ImageTk.PhotoImage(photo)
canvas.create_image(0,0,image=tkpi, anchor = NW)#display the screenshot
canvas.image = []
canvas.image.append(tkpi)#makes the screen stay
allowed["locations"] = []
for x in range(0,(X-50)/50+1):
for y in range(0,(Y-50)/50+1):
allowed["locations"].append((x,y))
return canvas
class App:
def __init__(self, master):
frame = Frame(master)
frame.pack()
canvas = reset(frame)
Start(canvas,frame)
root = Tk()
d = App(root)
w, h = root.winfo_screenwidth(), root.winfo_screenheight()
root.overrideredirect(1)#makes it full screen
root.focus_set()
root.geometry("%dx%d+0+0" % (w, h))
root.wait_window()
(73 lines of code oh no)
When I converted it to an exe with py2exe and then changed exe to scr (read that somewhere, a how to screen saver thing) but when it runs it brings up a black box before it takes the screen shot. also it doesn't close on mouse move so you have to actually alt-f4 out of it. and the mouse sits on top of the window created.