|
|
@ -15,28 +15,25 @@ class Team: |
|
|
|
self.posx, self.posy = 0,0 # coo de la dernière action |
|
|
|
self.ac_player = 0 # dernier joueur |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Gui: |
|
|
|
def __init__(self, ): |
|
|
|
self.terrain = Terrain() |
|
|
|
self.team = Team() |
|
|
|
self.list_button_menu = [] |
|
|
|
self.win = tkinter.Tk() |
|
|
|
self.canvas = tkinter.Canvas(self.win, width=self.terrain.width, height=self.terrain.height, background='#bbb') |
|
|
|
self.root = tkinter.Tk() |
|
|
|
self.canvas = tkinter.Canvas(self.root, width=self.terrain.width, height=self.terrain.height, background='#bbb') |
|
|
|
|
|
|
|
self.canvas.pack() |
|
|
|
|
|
|
|
# menu contextuel des actions |
|
|
|
self.action = tkinter.Menu(self.win, tearoff=0) |
|
|
|
self.action = tkinter.Menu(self.root, tearoff=0) |
|
|
|
self.action.add_command(label='marque', command=lambda: self.action_menu('marque')) |
|
|
|
self.action.add_command(label='rate', command=lambda: self.action_menu('rate')) |
|
|
|
|
|
|
|
|
|
|
|
# Menu contextuel des joueurs |
|
|
|
self.menu = tkinter.Menu(self.win, tearoff = 0) |
|
|
|
self.menu = tkinter.Menu(self.root, tearoff = 0) |
|
|
|
self.menu.add_command(label=self.team.players[0], command=lambda: self.show_sub_menu(self.team.players[0])) |
|
|
|
self.menu.add_command(label=self.team.players[1], command=lambda: self.show_sub_menu(self.team.players[1])) |
|
|
|
self.menu.add_command(label=self.team.players[2], command=lambda: self.show_sub_menu(self.team.players[2])) |
|
|
@ -57,12 +54,16 @@ class Gui: |
|
|
|
self.action.grab_release() |
|
|
|
|
|
|
|
def action_menu(self, action): |
|
|
|
# test si l'action est dans la liste des 3 points |
|
|
|
if ((self.team.posx-0)**2) + ((self.team.posy-self.terrain.height/2)**2) <= self.terrain.three_points**2 or ((self.team.posx-self.terrain.width)**2) + ((self.team.posy-self.terrain.height/2)**2) <= self.terrain.three_points**2: |
|
|
|
print('dunk') |
|
|
|
if action == 'marque': |
|
|
|
self.canvas.create_oval(self.team.posx-12, self.team.posy-12, self.team.posx+12, self.team.posy+12, fill='green') |
|
|
|
# with open('stat.txt', 'a') as f: |
|
|
|
|
|
|
|
else: |
|
|
|
self.canvas.create_oval(self.team.posx-12, self.team.posy-12, self.team.posx+12, self.team.posy+12, fill='red') |
|
|
|
with open('stat.txt', 'a') as f: |
|
|
|
line = self.team.ac_player+' '+action+' '+str(self.team.posx)+' '+str(self.team.posy)+'\n' |
|
|
|
f.write(line) # écriture de l'action dans le fichier |
|
|
|
|
|
|
|
def draw_terrain(self): |
|
|
|
# ligne des 3 points |
|
|
@ -80,6 +81,6 @@ class Gui: |
|
|
|
gui = Gui() |
|
|
|
gui.draw_terrain() |
|
|
|
|
|
|
|
gui.win.bind("<Button-1>", gui.context_menu) |
|
|
|
gui.root.bind("<Button-1>", gui.context_menu) |
|
|
|
|
|
|
|
gui.win.mainloop() |
|
|
|
gui.root.mainloop() |
|
|
|