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
|
# -*- coding: -utf-8 -*-
from Tkinter import *
def avance(xp,yp):
global x, y
x, y = x + xp, y + yp
can.coords(astre, x, y, x+30, y+30)
def deplacement():
global a
if x == 370:
a = -10
elif x == 0:
a = 10
avance(a,0)
a, x, y = 10, 0, 100
fen = Tk()
can = Canvas(fen, width=400, height=200, bg="black")
astre = can.create_oval(x, y, x+30, y+30, fill="white")
can.grid(row=0, column=0)
bou = Button(fen, text="Start", command=deplacement).grid(row=1, sticky=W)
print bou
fen.mainloop() |
Partager