Created
June 8, 2012 01:15
-
-
Save alfredodeza/2892822 to your computer and use it in GitHub Desktop.
Pecha Kucha random image driver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The web server: | |
import SimpleHTTPServer | |
import SocketServer | |
PORT = 8000 | |
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler | |
httpd = SocketServer.TCPServer(("", PORT), Handler) | |
print "serving at port", PORT | |
httpd.serve_forever() | |
# And the actual image driver | |
# note that `images` must be a directory that contains the actual | |
# images you want to display | |
from random import choice | |
import sys | |
import webbrowser | |
from time import sleep | |
import os | |
def get_images(): | |
return os.listdir('images') | |
def present(images): | |
for i in images: | |
uri = 'http://localhost:8000/images/' + i | |
webbrowser.open_new_tab(uri) | |
sleep(15) | |
def counter(second=0): | |
print "Presentation starting in... " | |
for i in range(0, 5): | |
print 5-i, | |
sys.stdout.flush() | |
sleep(1) | |
print "" | |
def main(range_count=20): | |
# Every 20 slides it pauses and asks if you want | |
# to continue. Ctrl-C to exit | |
raw_input("Press enter to start.") | |
image_list = get_images() | |
for x in range(0, len(image_list), range_count): | |
counter() | |
present(image_list[x:x+range_count]) | |
raw_input("Do you want to continue? [Enter] ") | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment