-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMonty.py
40 lines (35 loc) · 1.19 KB
/
Monty.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
'''Monty the motivational penguin, a free tool for astrophysics students at Oxford to help them destress when coding.
Written by Sam Spencer 13/3/2018, provided as is.'''
import numpy as np
import matplotlib.pyplot as plt
import csv
import os
from PIL import Image,ImageFont,ImageDraw
import time
import psutil
filedir=os.path.dirname(os.path.abspath(__file__))
database=[]
with open(filedir+'/quoteslib.csv') as csvfile:
quotesdat=csv.reader(csvfile,delimiter=';')
for row in quotesdat:
database.append(row[0])
while True:
quote=''
while len(quote)==0:
randomnumber=np.random.randint(len(database))
testquote=database[randomnumber]
if len(testquote)<50:
quote=testquote
else:
continue
penguin=Image.open(filedir+'/penguin-funny-blue-water-86405.jpeg')
draw = ImageDraw.Draw(penguin)
fnt = ImageFont.truetype('Pillow/Tests/fonts/FreeMono.ttf', 40)
draw.text((0, 300),database[randomnumber],(255,255,255),font=fnt)
penguin.show()
time.sleep(30)
penguin.close()
for proc in psutil.process_iter():
if proc.name() == "display":
proc.kill()
time.sleep(1200)