Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- """
- ESTRATEGIA PARA MODELAR UNA SITUACION REAL PARA IMPLEMENTAR UN PROGRAMA
- Programacion orientada a objetos POO OOP
- Objetos: es una "cosa", algo con propiedades (adjetivos --> atributos)
- que puede hacer cosas (verbos -> métodos)
- Clase: es un conjunto de objetos con propiedades en comùn
- Instancia: es un objeto en particular
- Los objetos interactuan entre sì enviándose mensajes
- Ejemplo: quiero simular una veterinaria
- Clases padres: animales, personas, objetos
- clases hijas: animales -> perros, gatos,loros, palomas,
- personas --> vendedor, vet, cliente
- obketos --> alimento, cuchas, prod_limpieza
- Instancia de clase vet: Dr Juan Gomez
- Instancia de clase animal--> perro: RinTinTin
- Atributos y metodos de perro
- Perro.color, Perro.edad, Perro.raza Ej: RinTinTin.edad = 3
- Perro.ladra, Perro.come, Perro.juega
- Ejemplos en Python
- Clases : int, float, str, list, dict, etc...
- Instancias de listas: lista = ['Jorge', 1, 23.4]
- Metodos de lista: append, insert, clear, ...
- Programacion gràfica:
- Clases: ventanas, botones, iconos, cajas_de_texto, etiquetas
- Instancia de una clase ventana: geany
- atributos: color de fondo, tipo y tamaño de letra, etc, titulo
- metodos: maximizar, minimizar, cerrar, mover
- TODO LOS OBJETOS DENTRO DE UNA VENTANA SE DENOMINAN WIDGETS
- """
- import tkinter as tk
- import pprint as p
- ###### Parte consola
- '''
- datos = [
- {"nombre":"Juan Robledo", "email":"rob@gmail.com", "edad":23, "telefono": 11222222},
- {"nombre":"Ana Garcia", "email":"annie@gmail.com", "edad":29, "telefono": 11257922},
- {"nombre":"Ricky Martin", "email":"ricky@gmail.com", "edad":50, "telefono": 11298522},
- ]
- '''
- datos = []
- def guardar_datos():
- global datos
- nombre = caja_nombre.get()
- email = caja_email.get()
- edad = caja_edad.get()
- telefono = caja_tel.get()
- persona = {"nombre":nombre, "email":email, "edad":edad, "telefono":telefono}
- datos.append(persona)
- p.pprint(f"\n{datos}")
- caja_nombre.delete(0,tk.END)
- caja_email.delete(0,tk.END)
- caja_edad.delete(0,tk.END)
- caja_tel.delete(0,tk.END)
- ###### Parte gráfica
- ventana = tk.Tk()
- ventana.config(width=400, height=300)
- ventana.title("Formulario de inscripción")
- ventana.resizable(0,0) # evita redimensionar la ventana
- #### campo nombre
- caja_nombre = tk.Entry()
- caja_nombre.place(x=150, y=20, width=200, height=25)
- etiqueta = tk.Label(text="Nombre")
- etiqueta.place(x=40, y=20)
- #### campo edad
- caja_edad = tk.Entry()
- caja_edad.place(x=150, y=70, width=200, height=25)
- etiqueta = tk.Label(text="Edad")
- etiqueta.place(x=40, y=70)
- #### campo email
- caja_email = tk.Entry()
- caja_email.place(x=150, y=120, width=200, height=25)
- etiqueta = tk.Label(text="Email")
- etiqueta.place(x=40, y=120)
- #### campo telefono
- caja_tel = tk.Entry()
- caja_tel.place(x=150, y=170, width=200, height=25)
- etiqueta = tk.Label(text="Teléfono")
- etiqueta.place(x=40, y=170)
- ##### botón
- boton = tk.Button(text="Guardar",command=guardar_datos)
- boton.place(x=150, y=220, width=100, height=40)
- ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement