I am working on a project to take screenshots of desktop and upload images to a server I want to develop a python app, when user starts that app it will start taking screenshots in random interval like between 2-5 min of interval I have the code that will take screenshot and I have tested it on ubuntu it is working properly. Code to capture screenshot
import gtk.gdk
import time
w = gtk.gdk.get_default_root_window()
sz = w.get_size()
print "The size of the window is %d x %d" % sz
pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,sz[0],sz[1])
pb = pb.get_from_drawable(w,w.get_colormap(),0,0,0,0,sz[0],sz[1])
ts = time.time()
filename = "screenshot"
filename += str(ts)
filename += ".png"
if (pb != None):
pb.save(filename,"png")
print "Screenshot saved to "+filename
else:
print "Unable to get the screenshot."
I want to run this code in random interval of 2-5 min how can I develop a script that will run this code in thread.