Browse Source

ca marche a peu près

master
BARRAUX Arthur 3 years ago
parent
commit
80f3dfdd02
  1. 48
      main.py
  2. 3
      stat.bbm

48
main.py

@ -27,6 +27,7 @@ class File:
with open(self.name, 'a') as f:
f.write(self.temp_data)
self.temp_data = ''
self.read_file()
def read_file(self):
with open(self.name, 'r') as f:
@ -36,8 +37,8 @@ class File:
class Gui:
def __init__(self):
self.terrain = Terrain()
self.team = 0
self.mode = 0
self.team = None
self.mode = None
self.root = tkinter.Tk()
self.root.title('BasketBall Analitycs®')
self.canvas = tkinter.Canvas(self.root, width=self.terrain.width, height=self.terrain.height, background='#bbb')
@ -65,11 +66,11 @@ class Gui:
self.root.config(menu=self.menubar)
if self.mode != 0:
print('here')
self.root.bind('<Button-2>', self.context_menu)
self.root.bind("<Control-o>", self.browse_open)
self.root.bind("<Control-n>", self.new)
self.root.bind("<Control-s>", self.save)
self.canvas.bind("<Button-1>", self.context_menu)
self.root.mainloop()
@ -101,11 +102,13 @@ class Gui:
def save(self, *event):
# sauvegarde du fichier
if self.file.name == 'untitled.bbm':
path = tkinter.filedialog.asksaveasfilename(initialdir = "~", title = "Select a File", filetypes = (("BasketBall Match", "*.bbm"), ("all files", "*.*")))
if len(path) != 0:
self.file.name = path
self.root.title(self.file.name)
if self.menu != None:
if self.file.name == 'untitled.bbm':
path = tkinter.filedialog.asksaveasfilename(initialdir = "~", title = "Select a File", filetypes = (("BasketBall Match", "*.bbm"), ("all files", "*.*")))
if len(path) != 0:
self.file.name = path
self.file.write_data()
self.root.title(self.file.name)
def browse_open(self, *event):
# ouvre un fichier
@ -139,6 +142,11 @@ class Gui:
self.statsubmenu.add_command(label=self.team.players[4], command=lambda: self.draw_player(self.team.players[4]))
self.statmenu.add_cascade(label="player", menu=self.statsubmenu)
self.statmenu.add_command(label='team', command=self.draw_team)
# actions menubar
self.actionmenu = tkinter.Menu(self.menubar, tearoff=0)
self.actionmenu.add_checkbutton(0, label='tirs', background='red')
# menu contextuel des actions
self.action = tkinter.Menu(self.root, tearoff=0)
self.action.add_command(label='marque', command=lambda: self.action_menu('marque'))
@ -152,13 +160,14 @@ class Gui:
self.menu.add_command(label=self.team.players[3], command=lambda: self.show_sub_menu(self.team.players[3]))
self.menu.add_command(label=self.team.players[4], command=lambda: self.show_sub_menu(self.team.players[4]))
self.root.bind('<Button-2>', self.contextmenu)
self.bind_click = "<Button-1>"
self.bind_ctrl_s = "<Control-s>"
def changemode(self, newmode):
if self.mode != newmode:
if newmode == 'stat':
self.menubar.add_cascade(label='stat', menu=self.statmenu)
self.menubar.add_cascade(label='actions', menu=self.actionmenu)
else:
self.menubar.delete(3)
self.mode = newmode
@ -168,10 +177,11 @@ class Gui:
items = self.canvas.find_all()
def context_menu(self, event):
self.team.posx, self.team.posy = event.x, event.y
self.coo = [event.x_root, event.y_root]
self.menu.tk_popup(event.x_root, event.y_root)
self.menu.grab_release()
if self.mode == "match":
self.team.posx, self.team.posy = event.x, event.y
self.coo = [event.x_root, event.y_root]
self.menu.tk_popup(event.x_root, event.y_root)
self.menu.grab_release()
def show_sub_menu(self, player):
self.team.ac_player = player
@ -190,9 +200,9 @@ class Gui:
self.canvas.create_oval(self.team.posx-12, self.team.posy-12, self.team.posx+12, self.team.posy+12, fill='green')
else:
self.canvas.create_oval(self.team.posx-12, self.team.posy-12, self.team.posx+12, self.team.posy+12, fill='red')
if self.temp_data == '':
self.root.title(self.file+' *')
self.temp_data += self.team.ac_player+' '+action+' '+str(score)+' '+str(self.team.posx)+' '+str(self.team.posy)+'\n'
if self.file.temp_data == '':
self.root.title(self.file.name+' *')
self.file.temp_data += self.team.ac_player+' '+action+' '+str(score)+' '+str(self.team.posx)+' '+str(self.team.posy)+'\n'
def clean_terrain(self):
"""Nettoie le terrain"""

3
stat.bbm

@ -10,3 +10,6 @@ alex marque 3 393 274
arthur rate 3 359 210
arthur marque 3 416 212
jl rate 3 448 234
alex rate 2 172 357
alex marque 3 269 292
louis marque 2 1043 277

Loading…
Cancel
Save