def get_screenshot(window): w, h = window.get_size() pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, w, h) pixbuf.get_from_drawable(window, window.get_colormap(), 0, 0, 0, 0, w, h) pixbuf.save(share.SCREENSHOT_PATH, share.SCREENSHOT_FORMAT) img = Image(share.SCREENSHOT_PATH) lock.remove_file(share.SCREENSHOT_PATH) return img
def run(): if os.path.exists(share.LOCK_PATH): lock.remove_file(share.LOCK_PATH) log.msg("check lock...") for i in xrange(5): time.sleep(0.5) if os.path.exists(share.LOCK_PATH): log.err("lock exist, exit") lock.create_file(share.RESTORE_PATH) os._exit(1) timer.timeout_add(500, lock.check_lock) share.MAIN_WINDOW.show() gtk.main()
def exit(*args): #log.msg("exit") lock.remove_file(share.LOCK_PATH) gtk.main_quit()