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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
from tkinter import *
from PIL import Image, ImageTk
import numpy as np
def cadre() :
var[0] = 'Cadre'
def bloque() :
var[0] = 'Bloque'
def out() :
var[0] = 'Out'
def goal() :
var[0] = 'Goal'
def J1() :
var[1] = 'Joueur 1'
def J2() :
var[1] = 'Joueur 2'
def J3() :
var[1] = 'Joueur 3'
def J4() :
var[1] = 'Joueur 4'
def localisation (event) :
clic.config(text='X = ' + str(event.x) + ' Y = ' + str(event.y))
var[2] = event.x ; var[3] = event.y
print(var)
coord.append(var)
print(coord)
def export() :
coord = np.asarray(coord)
np.savetxt('/Users/.../Desktop/Coord.csv', coord, delimiter=',')
def reset() :
coord = []
var = ['', '', 0, 0]
coord = []
var = ['','',0,0]
F = Tk()
F.title('Localisation tirs')
## ENSEMBLE DES BOUTONS ##
Boutons = Frame(F)
Boutons.pack(side=LEFT, padx=20, pady=20)
# Boutons TYPE
Type = PanedWindow(Boutons, orient=HORIZONTAL)
Button(Type, text='CADRE', borderwidth=1, width=15, command=cadre).grid(row=1, column=1)
Button(Type, text='BLOQUE', borderwidth=1, width=15, command=bloque).grid(row=1, column=2)
Button(Type, text='HORS CADRE', borderwidth=1, width=15, command=out).grid(row=1, column=3)
Button(Type, text='GOAL', borderwidth=1, width=15, command=goal).grid(row=1, column=4)
Type.columnconfigure(1, minsize = 150) ; Type.columnconfigure(2, minsize = 150) ; Type.columnconfigure(3, minsize = 150) ; Type.columnconfigure(4, minsize = 150)
Type.rowconfigure(1, minsize = 30)
Type.pack(side=TOP)
# Boutons Joueurs
Att = PanedWindow(Boutons, orient=HORIZONTAL)
Button(Att, text='Joueur 1', borderwidth=1, width=15, command=J1).grid(row=1, column=1)
Button(Att, text='Joueur 2', borderwidth=1, width=15, command=J2).grid(row=1, column=2)
Button(Att, text='Joueur 3', borderwidth=1, width=15, command=J3).grid(row=1, column=3)
Button(Att, text='Joueur 4', borderwidth=1, width=15, command=J4).grid(row=1, column=4)
Att.columnconfigure(1, minsize=150) ; Att.columnconfigure(2, minsize=150) ; Att.columnconfigure(3, minsize=150) ; Att.columnconfigure(4, minsize=150)
Att.rowconfigure(1, minsize=30)
Att.pack(side=TOP, pady=30)
# Boutons Save and reset
Options = PanedWindow(Boutons, orient=HORIZONTAL)
Button(Options, text='Export.csv', borderwidth=1, width=15, command=export).grid(row=1, column=1)
Button(Options, text='Reset', borderwidth=1, width=15, command=reset).grid(row=1, column=2)
Options.columnconfigure(1, minsize=150) ; Options.columnconfigure(2, minsize=150)
Options.pack(side=TOP, pady=60)
## TERRAIN ##
img = Image.open('/Users/.../Desktop/Field.png')
larg, haut = img.size
img = PhotoImage(file='/Users/.../Desktop/Field.png')
Field = Canvas(F, width=larg+50, height=haut+20)
Field.create_image(10, 10, anchor=NW, image=img)
Field.pack(side = RIGHT)
# Clic terrain
Field.bind('<Button-1>', localisation)
clic = Label(F, text='Coordonnees')
clic.pack()
F.mainloop() |
Partager