Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- import tkinter as tk
- from tkinter import ttk
- def imprimir_saludo():
- print("HOLA")
- def guardar_datos():
- global personas
- nombre = caja_nombre.get()
- email = caja_email.get()
- nac = caja_nac.get()
- direcc = caja_direc.get()
- tel = caja_tel.get()
- persona = {"nombre":nombre,
- "email": email,
- "nacionalidad": nac,
- "direccion":direcc,
- "telefono":tel}
- personas.append(persona)
- print("Datos guardados")
- for persona in personas:
- print(persona)
- # una vez impreso, borro todas las cajas
- caja_direc.delete(0,tk.END)
- caja_email.delete(0,tk.END)
- caja_nac.delete(0,tk.END)
- caja_nombre.delete(0,tk.END)
- caja_tel.delete(0,tk.END)
- def guardar_lista():
- seleccion = lista.get(lista.curselection())
- print(seleccion)
- def guardar_combo():
- seleccion = combo.get()
- print(seleccion)
- # lista que almacena los datos
- personas = []
- ################### ventana #######################################
- ventana = tk.Tk()
- ventana.title("FORMULARIO DE INSCRIPCION")
- ventana.config(width=400, height=800)
- # ventana.resizable(0,0) impide redimensionar la ventana
- ##### formulario de ingreso de datos ############
- # campo nombre
- caja_nombre = ttk.Entry()
- caja_nombre.place(x=150, y=40)
- etiqueta = tk.Label(text="Nombre")
- etiqueta.place(x=40, y=40)
- # campo email
- caja_email = ttk.Entry()
- caja_email.place(x=150, y=70)
- etiqueta = tk.Label(text="email")
- etiqueta.place(x=40, y=70)
- # campo nacionalidad
- caja_nac = ttk.Entry()
- caja_nac.place(x=150, y=100)
- etiqueta = tk.Label(text="Nacionalidad")
- etiqueta.place(x=40, y=100)
- # campo telefono
- caja_tel = ttk.Entry()
- caja_tel.place(x=150, y=130)
- etiqueta = tk.Label(text="Telefono")
- etiqueta.place(x=40, y=130)
- # campo direccion
- caja_direc = ttk.Entry()
- caja_direc.place(x=150, y=160)
- etiqueta = tk.Label(text="Direccion")
- etiqueta.place(x=40, y=160)
- # boton con ancho y alto según el tamaño del texto
- # boton = ttk.Button(text="ENTER", command=imprimir_saludo)
- # boton.place(x=50, y=10)
- # boton con ancho y alto
- boton = ttk.Button(text="GUARDAR", command=guardar_datos)
- boton.place(x=120, y=200, width=100, height=30)
- # imagenes dentro de etiquetas
- imagen = tk.PhotoImage(file="camion.png")
- label = ttk.Label(image=imagen)
- label.place(relx=0.5, rely=0.50, relwidth=0.5, relheight=0.5)
- # lista
- lista = tk.Listbox()
- lista.insert(0,"Python","Ruby","Erlang","GO")
- lista.place(x=10, y=270)
- boton = ttk.Button(text="Seleccionar", command=guardar_lista)
- boton.place(x=10, y=450)
- # lista desplegable
- combo = ttk.Combobox(state="readonly",
- values=["Rojo","Azul","Blanco","Marron","Negro"]
- )
- combo.place(x=10, y=480)
- boton = ttk.Button(text="Seleccionar", command=guardar_combo)
- boton.place(x=10, y=520)
- # casilla de verificación
- estado_casilla = tk.BooleanVar()
- estado_casilla.set("True")
- casilla = ttk.Checkbutton(text="ACEPTAR CONDICIONES", variable=estado_casilla)
- casilla.place(x=10, y=580)
- # barra de progreso horizontal
- barra = ttk.Progressbar(maximum=200)
- barra.place(x=10, y=650, width=200)
- barra.step(99.9)
- barra.start()
- # barra de progreso vertical
- barra = ttk.Progressbar(orient=tk.VERTICAL, maximum=100)
- barra.place(x=280, y=600, height=200)
- barra.step(99.9) # asegura que la barra llegue al final
- barra.start(20)
- ventana.mainloop()
Add Comment
Please, Sign In to add comment