-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.py
executable file
·110 lines (81 loc) · 2.56 KB
/
script.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
from tkinter import *
from tkinter.ttk import *
from PIL import Image, ImageTk
from urllib.request import urlopen
from io import BytesIO
import base64
import requests
import subprocess
try:
from StringIO import StringIO ## for Python 2
except ImportError:
from io import StringIO ## for Python 3
window=Tk()
window.geometry("700x700")
#width = screen.get_width()
#height = screen.get_height()
w = 700
h = 700
p = None
learn = None
play = None
playClicked = False
learnClicked = False
def learn_press():
global learnClicked
global p
learnClicked = not learnClicked
if learnClicked:
learn.config(text="Exit Learn!")
p = subprocess.Popen(["python3", "solved_hammer.py"])
print("LEARN!")
else:
learn.config(text="Learn!")
p.terminate()
def play_press():
global playClicked
global p
playClicked = not playClicked
if playClicked:
play.config(text="Exit Play!")
p = subprocess.Popen(["python3", "main.py"])
print("PLAY!")
else:
play.config(text="Play!")
p.terminate()
def exit_press():
global exitClicked
exitClicked = True
print("EXIT!")
p.terminate()
window.destroy()
learnClicked = False
playClicked = False
exitClicked = False
style = Style()
style.configure('W.TButton', font =
('helvetica', 20, 'bold'),
foreground = "#fe966e", background = "#0c9eb6", height = 150, width = 20)
# add widgets here
l = Label(window, text = "Test you skill!")
l.config(font =("helvetica", 30), foreground = "#0c9eb6", background = 'white')
#l.pack()
l.place(relx=0.5, rely=0.1, anchor=CENTER)
learn=Button(window, text="Learn!", style = 'W.TButton', command=learn_press)
learn.place(relx=0.5, rely=0.6, anchor=CENTER)
play=Button(window, text="Play!", style = 'W.TButton', command=play_press)
play.place(relx=0.5, rely=0.7, anchor=CENTER)
exit=Button(window, text="Exit!", style = 'W.TButton', command=exit_press)
exit.place(relx=0.5, rely=0.85, anchor=CENTER)
url = "https://mir-s3-cdn-cf.behance.net/project_modules/max_1200/f1a84856240191.59a64e6d80c00.jpg"
r = requests.get(url)
#pilImage = Image.open(StringIO(r.content))
pilImage = Image.open(BytesIO(r.content))
pilImage = pilImage.resize((200, 200), Image.ANTIALIAS)
image = ImageTk.PhotoImage(pilImage)
label = Label(image=image)
#label.pack()
label.place(relx=0.5, rely=0.35, anchor=CENTER)
window.configure(background='white')
window.title('Your AI Friend')
window.mainloop()