public
Last active

  • Download Gist
screensaver.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
import kivy
kivy.require('1.4.1')
 
import random, os
from kivy.app import App
from kivy.uix.image import Image
from kivy.core.window import Window
from kivy.clock import Clock
from kivy.config import Config
 
 
class PhotoScreensaver(App):
 
def __init__(self):
App.__init__(self)
self.photos = []
find_all_photos(self)
 
def build(self):
keyb = Window.request_keyboard(self.stop, self)
keyb.bind(on_key_down = self.key_pressed)
self.image = Image()
self.change_image()
Clock.schedule_interval(self.change_image, 10)
return self.image
 
def key_pressed(self, keyboard, keycode, text, modifiers):
self.stop()
 
def change_image(self, whatever = None):
self.image.source = random.choice(self.photos)
 
def add_photos(self, nothing, dirname, files):
for file in files:
if file.endswith('.jpg') or file.endswith('.JPG'):
self.photos.append(os.path.join(dirname, file))
 
def find_all_photos(app):
os.path.walk('/Users/larsga/data/bilder/privat', app.add_photos, None)
 
if __name__ == '__main__':
Config.set('graphics', 'fullscreen', '1')
Config.set('graphics', 'size', '0x0')
PhotoScreensaver().run()

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.