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
| from tkinter import *
CASE_SIZE = 20
CASE_NUMBER = 20
class Application(Frame):
def __init__(self, boss =None):
super().__init__()
self.pack()
self.game_status = 0
size = CASE_NUMBER*CASE_SIZE
size = CASE_NUMBER*CASE_SIZE
self.can = Canvas(self, width=size, height=size, bg ="black")
button_start = Button(self, text ='Stop/Start',command =self.launch_game)
button_start.pack(side = RIGHT)
self.pack()
self.tableau_object = update_tableau(self.game_status, self.can)
def launch_game(self):
self.game_status = not(self.game_status)
print(1,':', self.game_status)
self.tableau_object.change_game_statut(self.game_status)
class update_tableau(Application):
def __init__(self, game_status,can):
self.game_status = game_status
self.can = can
self.parcourt_tableau()
def change_game_statut(self, game_status):
self.game_status = game_status
def parcourt_tableau(self):
print(2,':', self.game_status)
self.can.after(200,self.parcourt_tableau)
launch = Application()
launch.mainloop() |
Partager