First I must comment that I have virtually no experience with tkinter So my help will be incomplete. That said, I'm telling you that Python brings in the library. csv that allows you to patch a file like notas.txtimport csv
notas = {}
with open('notas.txt', mode='r') as infile:
reader = csv.reader(infile, delimiter=';')
for linea in reader:
notas[linea[0]] = linea[1:]
valores = notas.keys()
With that notas is a dictionary containing{
'NOTAS':['EJERCICIO 1', 'EJERCICIO 2', 'EJERCICIO 3', 'EJERCICIO 4', 'EJERCICIO'],
'AAAA': ['2', '4', '7', '2', '6', '4'],
'BBBB': ['3', '5', '5', '4', '5', '5'],
'CCCC': ['4', '6', '5', '5', '4', '6'],
'DDDD': ['5', '7', '5', '6', '4', '4']
}
And valores It's a dict_keys:dict_keys(['NOTAS', 'AAAA', 'BBBB', 'CCCC', 'DDDD'])
You want to change the selector menu the notes of the pupil in the selector are printed. That's why you're listening when the selector's text value changes. But instead of texto.trace('r', LeerNotas)
It should be texto.trace('w', LeerNotas)
because, otherwise, you need a second click to refresh the data.In LeerNotas You're bringing correctly the NombreAlumnoBut you're not bringing the notes. I imagine when you put:etiqueta=Label(cuadro2, text=str(LeerNotas[y]), font=(None, 30),
relief=RIDGE)
That one. LeerNotas[y] should be the note obtained in the subject y. But LeerNotas It's a function. Not a list. You need an intermediate step to get the notes. For example:notas_alumno = notas.get(NombreDelAlumno)
for y in range(0, 5):
etiqueta = Label(
cuadro2,
text=str(notas_alumno[y]),
font=(None, 30),
relief=RIDGE)
etiqueta.grid(row=0, column=y, sticky=NSEW)
And with that you will have a behavior as seen in the image: You probably need the output of the notes in another format (e.g. by showing the subjects). But that leaves you with task, just like determining whether the student is approved or reproduced.