|
| 1 | +from tkinter import * |
| 2 | +from PIL import ImageTk, Image |
| 3 | +import time |
| 4 | +root = Tk() |
| 5 | +root.geometry('800x700') |
| 6 | + |
| 7 | +root.title('HELLO WORLD') |
| 8 | +img = ImageTk.PhotoImage(Image.open('assets/mascot.jpeg')) |
| 9 | +c = Canvas(root, width=800, height=700,bg='#474545') |
| 10 | +c.create_image(400, 300, image=img) |
| 11 | +c.place(x=0, y=0) |
| 12 | + |
| 13 | +l1 = Label(c) |
| 14 | +l2 = Label(c) |
| 15 | +l3 = Label(c) |
| 16 | +l4 = Label(c) |
| 17 | +i=0 |
| 18 | +Q1='How many letters are left if E and T leave the alphabet?' |
| 19 | +Q2='If 2 hens lay 2 eggs in 2 days,\n'' then how many eggs would 20 hens lay in 20 days?' |
| 20 | +Q3='I am a bird, I am a fruit and I am a person. What am I?' |
| 21 | + |
| 22 | +r=[Q1,Q2,Q3] |
| 23 | + |
| 24 | +def clear(): |
| 25 | + e1.delete(0,'end') |
| 26 | +def ans(): |
| 27 | + global i |
| 28 | + if r[i]==Q1: |
| 29 | + if e1.get()=='6': |
| 30 | + y() |
| 31 | + else: |
| 32 | + n() |
| 33 | + if r[i]==Q2: |
| 34 | + if e1.get() == '200': |
| 35 | + y() |
| 36 | + else: |
| 37 | + n() |
| 38 | + if r[i]==Q3: |
| 39 | + if e1.get() == 'kiwi': |
| 40 | + y() |
| 41 | + else: |
| 42 | + n() |
| 43 | + |
| 44 | +def opt(): |
| 45 | + global e1,A1,A2 |
| 46 | + e1 = Entry(root) |
| 47 | + e1.pack(padx=80, pady=70) |
| 48 | + A1 = Button(root, text='ok', font=('New Times Roman', 15), bg='green', relief=SUNKEN, command=ans) |
| 49 | + A1.place(x=250, y=100) |
| 50 | + A2 = Button(root, text='clear', font=('New Times Roman', 15), bg='green', relief=SUNKEN, command=clear) |
| 51 | + A2.place(x=500, y=100) |
| 52 | +def s2(): |
| 53 | + global m,Q,i |
| 54 | + if i==3: |
| 55 | + dis=Label(root,text="WELL PLAYED",height=20, width=50, font=('New Times Roman', 50), bg='#e2bb03') |
| 56 | + dis.pack() |
| 57 | + root.after(500, None) |
| 58 | + root.update() |
| 59 | + c1.pack_forget() |
| 60 | + try: |
| 61 | + Q=Label(root,text=r[i], font=('New Times Roman', 20)) |
| 62 | + Q.pack() |
| 63 | + except: |
| 64 | + print("") |
| 65 | + if r[i]==Q1: |
| 66 | + opt() |
| 67 | + if r[i]==Q2: |
| 68 | + opt() |
| 69 | + if r[i]==Q3: |
| 70 | + opt() |
| 71 | + |
| 72 | + |
| 73 | +def y(): |
| 74 | + global j,i |
| 75 | + j = Label(root, text='RIGHT ANSWER', height=20, width=50, font=('New Times Roman', 50), bg='#e2bb03') |
| 76 | + j.pack() |
| 77 | + root.after(1000,None) |
| 78 | + root.update() |
| 79 | + j.pack_forget() |
| 80 | + Q.pack_forget() |
| 81 | + A1.place_forget() |
| 82 | + A2.place_forget() |
| 83 | + e1.pack_forget() |
| 84 | + i=i+1 |
| 85 | + s2() |
| 86 | +def n(): |
| 87 | + j = Label(root, text='WRONG ANSWER,TRY AGAIN!', height=20, width=50, font=('New Times Roman', 30), bg='#e2bb03') |
| 88 | + j.pack() |
| 89 | + root.update() |
| 90 | + root.after(1000,None) |
| 91 | + root.update() |
| 92 | + j.pack_forget() |
| 93 | + |
| 94 | +def s1(): |
| 95 | + global c1,h3 |
| 96 | + root.after(500, None) |
| 97 | + root.update() |
| 98 | + c.place_forget() |
| 99 | + c1 = Canvas(root, width=800, height=700,bg='#FAA5A5') |
| 100 | + c1.pack() |
| 101 | + h2 = Label(c1, text='ARE YOU READY ', height=8, width=50, font=('New Times Roman', 50), bg='#FAA5A5') |
| 102 | + h2.pack() |
| 103 | + h3 = Button(c1, text='YES', height=5, width=15, font=('New Times Roman', 50), bg='Blue',relief=SUNKEN, command=s2) |
| 104 | + h3.pack(pady=10) |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | +def logscreen(): |
| 109 | + root.after(500, None) |
| 110 | + root.update() |
| 111 | + l1.configure(text='SMART BRAIN PRESENTS', height=0, width=25, font=('New Times Roman', 20), bg='#FAA5A5') |
| 112 | + l1.place(x=240, y=40) |
| 113 | + root.after(1000, None) |
| 114 | + root.update() |
| 115 | + l2.configure(text='TEST', font=('New Times Roman', 20), bg='#e2bb03') |
| 116 | + l2.place(x=140, y=310) |
| 117 | + root.after(1000, None) |
| 118 | + root.update() |
| 119 | + l3.configure(text='YOUR', font=('New Times Roman', 20), bg='#474545', fg='white') |
| 120 | + l3.place(x=440, y=200) |
| 121 | + root.after(1000, None) |
| 122 | + root.update() |
| 123 | + l4.configure(text='BRAIN', font=('New Times Roman', 20), bg='#e2bb03') |
| 124 | + l4.place(x=700, y=300) |
| 125 | + root.after(1000, None) |
| 126 | + root.update() |
| 127 | + s1() |
| 128 | + |
| 129 | + |
| 130 | +logscreen() |
| 131 | + |
| 132 | +root.mainloop() |
0 commit comments