kailive.py 661 B

12345678910111213141516171819202122232425262728293031323334
  1. import threading
  2. import time
  3. import kaiscr
  4. from gi.repository import Gtk, GdkPixbuf, GLib
  5. takescreenshot = kaiscr.TakeScreenshot().screenshot
  6. window = Gtk.Window()
  7. window.connect("destroy", Gtk.main_quit)
  8. img = None
  9. def update_pic():
  10. global img
  11. global takescreenshot
  12. while 1:
  13. loader = GdkPixbuf.PixbufLoader()
  14. loader.write(takescreenshot())
  15. pb = loader.get_pixbuf()
  16. if not img:
  17. img = Gtk.Image.new_from_pixbuf(pb)
  18. else:
  19. img.set_from_pixbuf(pb)
  20. loader.close()
  21. t = threading.Thread(target=update_pic)
  22. t.start()
  23. time.sleep(0.5)
  24. window.add(img)
  25. window.show_all()
  26. Gtk.main()