-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path8ball.py
32 lines (24 loc) · 900 Bytes
/
8ball.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
# Made by Christine Garcia
# After self-learning Python and Tkinter basics
import random
from tkinter import *
window = Tk()
window.minsize(300, 50)
window.title("8ball of words")
# excerpts of answers taken from: https://magic-8ball.com/magic-8-ball-answers/
Eightball_list = [ "It is certain", "It is decidedly so", "Without a doubt", "Yes", "Most likely",
"No", "Don't count on it", "My sources say no", "Very doubtful", "My reply is no",
"Reply hazy, try again", "Ask again later", "Better not tell you now" ]
answer = Label(window)
def printAnswer(event):
answer.configure(text=(random.choice(Eightball_list)))
answer.pack()
label = Label(window, text="What is your question?")
label.pack()
question = Entry(window)
question.pack()
button = Button(window, text="Ask")
button.bind('<Button-1>', printAnswer)
window.bind('<Return>', printAnswer)
button.pack()
window.mainloop()