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
| from tkinter import *
import csv
class liveFen(object):
def __init__(self, f, ficCSV):
self.root = Tk()
self.fichier = f
self.ficCSV = ficCSV
self.lb1 = Label(self.root)
self.lb1.grid(row=0, column=0, columnspan=3)
Button(self.root, text="Lire les instructions",
command=lambda choixFic="A1":self.evenSuiv(choixFic)).grid(row=1, column=2)
Button(self.root, text="Lire les instructions",
command=lambda choixFic="A2":self.evenSuiv(choixFic)).grid(row=2, column=2)
self.root.protocol("WM_DELETE_WINDOW", self.on_quit)
self.root.mainloop()
def evenSuiv(self, choixFic):
try:
ligne = self.ficCSV.__next__()
except StopIteration:
self.fichier.close()
ligne = None
if ligne:
# Initialisation des variables
tempsEvenement = float(ligne[0])
numero = ligne[1]
typeEvenement = ligne[2]
commentaireEvenement = ligne[3]
self.lb1.config(text = commentaireEvenement)
#self.root.update()
self.root.after(1500, self.evenSuiv(choixFic)) # en ms
def on_quit(self):
self.root.quit()
def liveGraph(fichier, ficCSV):
""" Affichage en direct par l'intermédiaire de la lecture d'un fichier csv
"""
#tempsEvenementPrecedent = 0.000
f = liveFen(fichier, ficCSV)
fichier = open("log\\ficCSV.csv", "r")
ficCSV = csv.reader(fichier, delimiter=';')
#liveGraph(fichier, ficCSV)
liveFen(fichier, ficCSV) |
Partager