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
| from tkinter import *
import random
import time
class Balle:
def _init_(self, canvas, couleur):
self.canvas = canvas
self.id = Canvas.create_oval(10, 10, 25, 25, fill=couleur)
self.canvas.move(self.id, 245, 100)
def dessiner(self):
self.canvas.move(self.id, 0, -1)
#15
tk = Tk()
tk.title("Jeu")
tk.resizable(0,0)
tk.wm_attributes("-topmost",1)
canvas = Canvas(tk, bg='ivory', width=500, heigh=400, bd=0, highlightthickness=0)
canvas.pack()
tk.update()
balle = Balle(canvas, 'red')
while 1:
balle.dessiner()
tk.update_idletasks()
tk.update()
time.sleep(0.01) |
Partager