-
Notifications
You must be signed in to change notification settings - Fork 0
/
ImportingHomework3.py
182 lines (145 loc) · 6.49 KB
/
ImportingHomework3.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
from tkinter import *
import time as t
import tkinter.font as font
global lbl1, e, slider, btn1, x, Qcount, Questions, window, btn1, status, r, MODES, mode, text, callBack, newbtn, clicked, dropDown, chkbx, chkbx2, chkbx3, feelings, var, var2, var3, r, feelingslbl, name, age, chkbxlbl, sport, iceCream, iceCream2, iceCream3, chkbxlbl2, chkbxlbl3
window = Tk()
window.title("Getting to know you game")
window.iconbitmap('target_goal_icon_152113.ico')
window.geometry("400x400") #width x height
window['bg'] = 'green'
Questions = ['Hello, what should I call you?', #textbox - Done
'How old are you?', #slider - Done
'What is your favorite sport?', #dropdown/option menu - Done
'Which flavor of ice cream is your favorite?', #Checkboxes - Done
'How are you feeling today?'] #radio
x = 0
Qcount = Questions[x]
b=0
lbl1 = Label(window,text=Qcount, bg='green')
lbl1.place(x=20, y=20)
lbl1.pack(pady=10)
e = Entry(window, width=50, fg='blue')
e.pack(pady=10)
def btnClick():
global lbl1, e, slider, btn1, x, Qcount, Questions, window, btn1, b, r, MODES, mode, text, status, newbtn, callBack, clicked, dropDown, chkbx, var, var2, var3, chkbx2, chkbx3, feelings, r, feelingslbl, name, age, chkbxlbl, sport, iceCream, iceCream2, iceCream3, chkbxlbl2, chkbxlbl3
if b == 0:
e.get()
name = e.get()
e.pack_forget()
lbl1.pack_forget()
x+=1
status.pack_forget()
lbl1 = Label(window, text=Questions[x], bg='green')
lbl1.pack(pady=10)
slider = Scale(window,from_=0, to=100, bg='green')
slider.pack()
btn1.pack_forget()
#btn1 = Button(window, text="Submit", command= lambda: btnClick() , fg= 'black', bg='#33FFC4', padx=10)
btn1.pack()
status = Label(window, text="Question " + str(x+1) + " of " + str(len(Questions)), bd=1, relief=SUNKEN, pady=5, bg='green' )
status.pack()
b += 1
elif b ==1:
age = slider.get()
slider.pack_forget()
lbl1.pack_forget()
x+=1
status.pack_forget()
lbl1 = Label(window, text=Questions[x], bg='green')
lbl1.pack(pady=10)
clicked = StringVar()
clicked.set("Football")
dropDown = OptionMenu(window, clicked, "Football", "Hockey", "Baseball", "Basketball")
dropDown.pack()
btn1.pack_forget()
btn1.pack()
status = Label(window, text="Question " + str(x+1) + " of " + str(len(Questions)), bd=1, relief=SUNKEN, pady=5, bg='green' )
status.pack()
b += 1
elif b == 2:
sport = clicked.get()
dropDown.pack_forget()
lbl1.pack_forget()
x += 1
status.pack_forget()
lbl1 = Label(window, text=Questions[x], bg='green')
lbl1.pack(pady=10)
var = StringVar()
var2 = StringVar()
var3 = StringVar()
chkbx = Checkbutton(window, text="Chocolate", variable=var, onvalue="Chocolate", offvalue="", bg='green')
chkbx.deselect()
chkbx.pack(anchor=W)
chkbx2 = Checkbutton(window, text="Vanilla", variable=var2, onvalue="Vanilla", offvalue="", bg='green')
chkbx2.deselect()
chkbx2.pack(anchor=W)
chkbx3 = Checkbutton(window, text="Strawberry", variable=var3, onvalue="Strawberry", offvalue="", bg='green')
chkbx3.deselect()
chkbx3.pack(anchor=W)
btn1.pack_forget()
btn1.pack()
status = Label(window, text="Question " + str(x+1) + " of " + str(len(Questions)), bd=1, relief=SUNKEN,pady=5, bg='green' )
status.pack()
b += 1
elif b == 3:
chkbx.pack_forget()
chkbx2.pack_forget()
chkbx3.pack_forget()
age = slider.get()
slider.pack_forget()
lbl1.pack_forget()
x += 1
status.pack_forget()
btn1.pack_forget()
lbl1 = Label(window, text=Questions[x], bg='green')
lbl1.pack(pady=10)
MODES = [
("Happy", "Happy"),
("So-So", "So-So"),
("Sad", "Sad", ),
("Angry","Angry")
]
r = StringVar()
r.set("Happy")
for text, mode in MODES:
Radiobutton(window, text=text, variable=r, value=mode, bg='green').pack(anchor=W)
feelings = Label(window, text=r.get())
#feelings.pack()
newbtn = Button(window, text="Submit", command= lambda: clicked(r.get()), fg= 'black', bg='#33FFC4', padx=10)
newbtn.pack()
def clicked(value):
global b, feelingslbl,lbl1, name, window, age, sport, chkbxlbl, feelings, MODES, mode, text, hey, newbtn, r, iceCream, iceCream2, iceCream3, chkbxlbl2, chkbxlbl3, var, var2, var3
window.destroy()
window = Tk()
window.title("Final Results")
window.iconbitmap('target_goal_icon_152113.ico')
window.geometry("300x300") #width x height
window['bg'] = 'blue'
# newbtn.pack_forget()
# lbl1.pack_forget
chkbxlbl = Label(window, text=var.get())
chkbxlbl2 = Label(window, text=var2.get())
chkbxlbl3 = Label(window, text=var3.get())
iceCream = var.get() #chkbxlbl.cget('text')
iceCream2 = var2.get() #chkbxlbl2.cget('text')
iceCream3 = var3.get() #chkbxlbl3.cget('text')
feelingslbl = Label(window, text=value)
var4 = r.get()
b+=1
# lbl1.pack_forget()
lbl1 = Label(window, text="You are " + str(name) + ".\nYour age is " + str(age) + "\nYour favorite sport is " + str(sport) + ".\nYour favorite flavor of ice cream is " + str(iceCream)+ str(iceCream2)+ str(iceCream3) + ".\nAnd you are feeling " + str(var4) + ".\nThanks for playing! Have a great day =)", padx=100, pady=100, bg='blue', fg='white')
lbl1.pack(pady=10)
status = Label(window, text="Question " + str(x+1) + " of " + str(len(Questions)), bd=1, relief=SUNKEN,pady=5, bg='green' )
status.pack()
elif b == 4:
btn1.pack_forget()
status.pack_forget()
status = Label(window, text="Question " + str(x+1) + " of " + str(len(Questions)), bd=1, relief=SUNKEN,pady=5, bg='green' )
status.pack()
b += 1
exit()
btn1 = Button(window, text="Submit", command= lambda: btnClick() , fg= 'black', bg='#33FFC4', padx=10)
btn1.pack()
status = Label(window, text="Question " + str(x+1) + " of " + str(len(Questions)), bd=1, relief=SUNKEN, pady=5, bg='green' )
status.pack()
window.mainloop()