-
Notifications
You must be signed in to change notification settings - Fork 0
/
tg.py~
59 lines (36 loc) · 1.16 KB
/
tg.py~
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
45
46
47
48
49
50
51
52
53
54
55
import pygame,sys
import urllib
from pygame.locals import *
def getUrls():
feed = urllib.urlopen("http://www.reddit.com/r/teen_girls/new/.json?sort=new")
true,false,null = True,False,None
json = eval(feed.read())
urls = [item["data"].get("url","") for item in json["data"]["children"]]
urls = filter(lambda x:x,urls)
return urls
pygame.init()
fpsClock = pygame.time.Clock()
window = pygame.display.set_mode((640,480))
pygame.display.set_caption("Pygame sample.")
urls = []
def setImage(url):
file("tmp.img","w").write(urllib.urlopen("http://i.imgur.com/QFBbah.jpg").read())
img = pygame.image.load("tmp.img")
window = pygame.display.set_mode((img.get_width(),img.get_height()))
# window.fill((255,255,255))
window.blit(img,(0,0))
pygame.display.update()
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if urls:
setImage(urls[0])
urls.pop(0)
else:
urls = getUrls()
fpsClock.tick(1)
import urllib
import pprint
pprint.pprint(json)