#!/usr/bin/env python # -*- coding: utf-8 -*- # import tkinter as tk alumnos = {} def ver_lista(): global alumnos if alumnos: print("\nLista de alumnos:") for k,v in alumnos.items(): print(f"Nombre: {k} - Cursos: {v}") else: print("No existen alumnos") def ver_cursos(): global alumnos caja_cursos.delete(0,tk.END) hallado = False nombre = caja_nombre.get() for k,v in alumnos.items(): if k == nombre: caja_cursos.insert(0,alumnos[nombre]) hallado = True break if not hallado: caja_cursos.insert(0,"No existe el alumno") def agregar(): global alumnos nombre = caja_nombre.get() cursos = int(caja_cursos.get()) alumnos[nombre] = cursos ventana = tk.Tk() ventana.title("PROYECTO INTEGRADOR") ventana.config(width=350, height=350) # botones boton = tk.Button(text="Ver lista de alumnos", command=ver_lista) boton.place(x=20, y=20, width=130, height=30) boton = tk.Button(text="Ver cantidad de cursos", command=ver_cursos) boton.place(x=150, y=200, width=130, height=30) boton = tk.Button(text="Agregar a la lista", command=agregar) boton.place(x=20, y=200, width=100, height=30) # campo nombre del alumno etiqueta = tk.Label(text="Nombre del alumno") etiqueta.place(x=20, y=100) caja_nombre = tk.Entry() caja_nombre.place(x=150, y=100, width=150, height=25) # campo cursos etiqueta = tk.Label(text="Cursos") etiqueta.place(x=80, y=140) caja_cursos = tk.Entry() caja_cursos.place(x=150, y=140, width=150, height=25) ventana.mainloop()