[Tutor] Whack-a-mole

Ben Smith Ben.Smith at arnoldkeqms.com
Wed Oct 1 17:59:36 CEST 2014


Hi, Can anyone help explain why you can keep hitting the Mole even when hittable should be False?

from tkinter import *

root = Tk()
#root.state('zoomed')
sec = 0
points=0
pic=PhotoImage(file='Dirt.gif')
pic2=PhotoImage(file='Mole.gif')
hittable=False

def HIT():
    if hittable==True:
        global points;points+=1
        butty.configure(image=pic)
        labby.configure(text=points)

def tick():
    global sec, hittable
    sec += 1
    if sec == 3:
        hittable=True
        butty.configure(image=pic2)
    if sec==6:
        hittable=False
        butty.configure(image=pic)
    time['text'] = sec
    time.after(1000, tick)

time = Label(root)
time.pack()
labby = Label(root, text="POINTS");labby.pack()
Button(root, text='Start', command=tick).pack()

butty=Button(root, image=pic, command=HIT);butty.pack()

root.mainloop()



This email and any attachments sent with it are intended only for the named recipient. If you are not that person please contact us immediately through our website and delete this message from your computer. You should not disclose the content nor take, retain or distribute any copies. No responsibility is accepted by AKS, United Learning or any associated entity for the contents of e-mails unconnected with their business. No responsibility is accepted for any loss or damage caused due to any virus attached to this email.

AKS is part of United Learning, comprising: UCST (Registered in England No: 2780748. Charity No. 1016538) and ULT (Registered in England No. 4439859. An Exempt Charity).
Companies limited by guarantee.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20141001/e1ccf06c/attachment.html>


More information about the Tutor mailing list