-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtkinteractivity.py
60 lines (39 loc) · 1.48 KB
/
tkinteractivity.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
import tkinter
class Application(tkinter.Frame):
def __init__(self,master):
tkinter.Frame.__init__(self,master)
self.pack()
self.points=0
self.ask1button=tkinter.Button()
self.ask1button["text"]="ask1"
self.ask1button["command"]=self.ask1
self.ask1button.pack()
self.ask2button=tkinter.Button()
self.ask2button["text"]="ask2"
self.ask2button["command"]=self.ask2
self.ask2button.pack()
self.ask3button=tkinter.Button()
self.ask3button["text"]="ask3"
self.ask3button["command"]=self.ask3
self.ask3button.pack()
self.pointbutton=tkinter.Button()
self.pointbutton["text"]="points"
self.pointbutton["command"]=self.point
self.pointbutton.pack()
def ask1(self):
response=tkinter.messagebox.askyesno("Question","Is the sun yellow?")
if (response==True):
self.points+=1
def ask2(self):
response=tkinter.messagebox.askyesno("Question","Is wood edible?")
if (response==True):
self.points+=1
def ask3(self):
response=tkinter.messagebox.askyesno("Question","Is fried chicken made of pigs?")
if (response==True):
self.points+=1
def point(self):
tkinter.messagebox.showinfo("Points","Your total points is: %i"%(self.points))
root=tkinter.Tk()
app=Application(master=root)
app.mainloop()