Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- import tkinter as tk
- def ver_lista():
- global alumnos
- if len(alumnos) == 0:
- print("No existen alumnos inscriptos")
- else:
- print("Nombre cursos")
- print("-----------------")
- for nombre,cursos in alumnos.items():
- print(nombre, cursos)
- def agregar_alumno():
- global alumnos
- nombre = caja_nombre.get()
- cursos = caja_cursos.get()
- alumnos[nombre] = cursos
- borrar_nombre.set("")
- borrar_cursos.set("")
- def ver_cursos():
- global alumnos
- nombre = caja_nombre.get()
- if nombre in alumnos.keys():
- print(f"El alumno {nombre} tiene {alumnos[nombre]} cursos")
- else:
- print(f"No existe el alumno {nombre}")
- ############## main ###########################
- alumnos = {} # alumnos = {"Pepe":4, "Juana":3, "Luis":11}
- ventana = tk.Tk()
- ventana.config(width=600, height=400)
- ventana.title("Proyecto Integrador")
- borrar_nombre = tk.StringVar()
- borrar_nombre.set("")
- borrar_cursos = tk.StringVar()
- borrar_cursos.set("")
- # botones
- boton = tk.Button(text="Ver lista de alumnos", command=ver_lista)
- boton.place(x=10,y=10, width=150, height=30)
- boton = tk.Button(text="Agregar a la lista", command=agregar_alumno)
- boton.place(x=10,y=220, width=150, height=30)
- boton = tk.Button(text="Ver cantidad de cursos", command=ver_cursos)
- boton.place(x=200,y=220, width=150, height=30)
- # etiquetas
- etiqueta = tk.Label(text="Nombre alumno")
- etiqueta.place(x=20, y=80)
- etiqueta = tk.Label(text="Cursos")
- etiqueta.place(x=20, y=140)
- # cajas de texto
- caja_nombre = tk.Entry(textvariable = borrar_nombre)
- caja_nombre.place(x=150, y=80)
- caja_cursos = tk.Entry(textvariable = borrar_cursos)
- caja_cursos.place(x=150, y=140)
- ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment