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
| from tkinter import*
import random
def clickcan(event):
???
root = Tk ()
root.configure (bg='#ffffff')
root.geometry ("1366x768+10+10")
root.wm_state(newstate="zoomed")
root.title ("Cliques sur la patate")
bouton = Button(root, text='Quitter le jeu', command = root.destroy)
bouton.configure (bg = 'grey')
bouton.place(x=1250,y=5)
titre = Label(root, text="Attrapes la patate !")
titre.place (x=375, y=5)
titre.configure (bg='#ffffff')
titre.config (font=('Comic sans ms',50,'bold'))
titre.config (fg='red')
can=Canvas(root,width=160,height=160,bg='white')
photo=PhotoImage(file='patate.gif')
item = can.create_image(80,80,image=photo)
can.pack()
x=500
y=300
randomx = random.randint(1,6)
randomy = random.randint(1,6)
while (can!=True):
if (x>0 and x<1000):
x=x+randomx
else :
x= x-randomx
if (y>0 and y<600) :
y=randomy+3
else :
y= randomy-7
can.place(x=x,y=y)
root.update()
root.mainloop () |
Partager