Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- """
- Posicionamiento PLACE"""
- import tkinter as tk
- from tkinter import ttk
- datos = [] # datos = [dato1, dato2,]
- def guardar():
- dato = {} # dato = {"nombre":nom, "email":mail, "tel":tel}
- nom = nombre.get()
- if nom:
- print(f"Nombre {nom} guardado")
- dato["nombre"] = nom
- else:
- print("No se ha ingresado ningún nombre")
- mail = email.get()
- if mail and "@" in mail:
- print(f"Email {mail} guardado")
- dato["email"] = mail
- else:
- print("No se ha ingresado ningún email")
- tel = telefono.get()
- if tel:
- print(f"Telefono {tel} guardado")
- dato["tel"] = tel
- else:
- print("No se ha ingresado ningún telefono")
- if nom and mail and tel:
- datos.append(dato)
- print("Datos de usuario almacenados")
- def mostrar_lista():
- seleccion = lista.get(lista.curselection())
- print(seleccion)
- def mostrar_combo():
- seleccion = combo.get()
- print(seleccion)
- ventana = tk.Tk()
- ventana.title("PLACE")
- ventana.config(width=400, height=800)
- ############## Formulario de inscripción ################
- ##### campo nombre ################
- nombre = ttk.Entry()
- nombre.insert(0,"Ej: Juan")
- nombre.place(x=10, y=10, width=200, height=25)
- etiqueta = ttk.Label(text="Nombre")
- etiqueta.place(x=220, y=10)
- ##### campo email ################
- email = ttk.Entry()
- email.place(x=10, y=50, width=200, height=25)
- etiqueta = ttk.Label(text="email")
- etiqueta.place(x=220, y=50)
- ##### campo telefono ################
- telefono = ttk.Entry()
- telefono.place(x=10, y=90, width=200, height=25)
- etiqueta = ttk.Label(text="telefono")
- etiqueta.place(x=220, y=90)
- # boton
- boton = ttk.Button(text="Guardar", command=guardar)
- boton.place(x=50, y=130)
- #### listas
- lista = tk.Listbox()
- lista.insert(0,"Python", "C++", "Java", "C#")
- lista.place(x=10, y=160)
- boton = ttk.Button(text="Lista", command=mostrar_lista)
- boton.place(x=50, y=340)
- ### imagen dentro de una etiqueta
- imagen = tk.PhotoImage(file="camion.png")
- label = ttk.Label(image=imagen)
- label.place(relx=0.5, rely=0.5, relwidth=0.5, relheight=0.5)
- ##### lista desplegable
- combo = ttk.Combobox(state="readonly",
- values=["C","C++","Erlang","Ruby","R"]
- )
- combo.place(x=10, y=400)
- boton = ttk.Button(text="Lista", command=mostrar_combo)
- boton.place(x=50, y=430)
- ##### casilla de verificacion
- valor_casilla = tk.BooleanVar()
- casilla = ttk.Checkbutton(text="Acepta las condiciones", variable=valor_casilla)
- valor_casilla.set("True")
- casilla.place(x=50, y=480)
- ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement