|
@ -27,6 +27,7 @@ class File: |
|
|
with open(self.name, 'a') as f: |
|
|
with open(self.name, 'a') as f: |
|
|
f.write(self.temp_data) |
|
|
f.write(self.temp_data) |
|
|
self.temp_data = '' |
|
|
self.temp_data = '' |
|
|
|
|
|
self.read_file() |
|
|
|
|
|
|
|
|
def read_file(self): |
|
|
def read_file(self): |
|
|
with open(self.name, 'r') as f: |
|
|
with open(self.name, 'r') as f: |
|
@ -36,8 +37,8 @@ class File: |
|
|
class Gui: |
|
|
class Gui: |
|
|
def __init__(self): |
|
|
def __init__(self): |
|
|
self.terrain = Terrain() |
|
|
self.terrain = Terrain() |
|
|
self.team = 0 |
|
|
self.team = None |
|
|
self.mode = 0 |
|
|
self.mode = None |
|
|
self.root = tkinter.Tk() |
|
|
self.root = tkinter.Tk() |
|
|
self.root.title('BasketBall Analitycs®') |
|
|
self.root.title('BasketBall Analitycs®') |
|
|
self.canvas = tkinter.Canvas(self.root, width=self.terrain.width, height=self.terrain.height, background='#bbb') |
|
|
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) |
|
|
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-o>", self.browse_open) |
|
|
self.root.bind("<Control-n>", self.new) |
|
|
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() |
|
|
self.root.mainloop() |
|
|
|
|
|
|
|
@ -101,10 +102,12 @@ class Gui: |
|
|
|
|
|
|
|
|
def save(self, *event): |
|
|
def save(self, *event): |
|
|
# sauvegarde du fichier |
|
|
# sauvegarde du fichier |
|
|
|
|
|
if self.menu != None: |
|
|
if self.file.name == 'untitled.bbm': |
|
|
if self.file.name == 'untitled.bbm': |
|
|
path = tkinter.filedialog.asksaveasfilename(initialdir = "~", title = "Select a File", filetypes = (("BasketBall Match", "*.bbm"), ("all files", "*.*"))) |
|
|
path = tkinter.filedialog.asksaveasfilename(initialdir = "~", title = "Select a File", filetypes = (("BasketBall Match", "*.bbm"), ("all files", "*.*"))) |
|
|
if len(path) != 0: |
|
|
if len(path) != 0: |
|
|
self.file.name = path |
|
|
self.file.name = path |
|
|
|
|
|
self.file.write_data() |
|
|
self.root.title(self.file.name) |
|
|
self.root.title(self.file.name) |
|
|
|
|
|
|
|
|
def browse_open(self, *event): |
|
|
def browse_open(self, *event): |
|
@ -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.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_cascade(label="player", menu=self.statsubmenu) |
|
|
self.statmenu.add_command(label='team', command=self.draw_team) |
|
|
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 |
|
|
# menu contextuel des actions |
|
|
self.action = tkinter.Menu(self.root, 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='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[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.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): |
|
|
def changemode(self, newmode): |
|
|
if self.mode != newmode: |
|
|
if self.mode != newmode: |
|
|
if newmode == 'stat': |
|
|
if newmode == 'stat': |
|
|
self.menubar.add_cascade(label='stat', menu=self.statmenu) |
|
|
self.menubar.add_cascade(label='stat', menu=self.statmenu) |
|
|
|
|
|
self.menubar.add_cascade(label='actions', menu=self.actionmenu) |
|
|
else: |
|
|
else: |
|
|
self.menubar.delete(3) |
|
|
self.menubar.delete(3) |
|
|
self.mode = newmode |
|
|
self.mode = newmode |
|
@ -168,6 +177,7 @@ class Gui: |
|
|
items = self.canvas.find_all() |
|
|
items = self.canvas.find_all() |
|
|
|
|
|
|
|
|
def context_menu(self, event): |
|
|
def context_menu(self, event): |
|
|
|
|
|
if self.mode == "match": |
|
|
self.team.posx, self.team.posy = event.x, event.y |
|
|
self.team.posx, self.team.posy = event.x, event.y |
|
|
self.coo = [event.x_root, event.y_root] |
|
|
self.coo = [event.x_root, event.y_root] |
|
|
self.menu.tk_popup(event.x_root, event.y_root) |
|
|
self.menu.tk_popup(event.x_root, event.y_root) |
|
@ -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') |
|
|
self.canvas.create_oval(self.team.posx-12, self.team.posy-12, self.team.posx+12, self.team.posy+12, fill='green') |
|
|
else: |
|
|
else: |
|
|
self.canvas.create_oval(self.team.posx-12, self.team.posy-12, self.team.posx+12, self.team.posy+12, fill='red') |
|
|
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 == '': |
|
|
if self.file.temp_data == '': |
|
|
self.root.title(self.file+' *') |
|
|
self.root.title(self.file.name+' *') |
|
|
self.temp_data += self.team.ac_player+' '+action+' '+str(score)+' '+str(self.team.posx)+' '+str(self.team.posy)+'\n' |
|
|
self.file.temp_data += self.team.ac_player+' '+action+' '+str(score)+' '+str(self.team.posx)+' '+str(self.team.posy)+'\n' |
|
|
|
|
|
|
|
|
def clean_terrain(self): |
|
|
def clean_terrain(self): |
|
|
"""Nettoie le terrain""" |
|
|
"""Nettoie le terrain""" |
|
|