Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- # metodo place
- import tkinter as tk
- from tkinter import ttk
- ############
- def guardar_datos():
- global datos
- nombre = caja_nombre.get()
- tel = caja_tel.get()
- dato = {'nombre':nombre, 'tel':tel}
- datos.append(dato)
- print("\n",datos)
- # borro las cajas
- caja_nombre.delete(0, tk.END)
- caja_tel.delete(0, tk.END)
- def listbox():
- seleccion = lista.get(lista.curselection())
- print(seleccion)
- def desplegable():
- seleccion = combo.get()
- print(seleccion)
- ###################################
- datos = [] # creo una lista para almacenar los datos
- ventana = tk.Tk()
- ventana.title("Posicionamiento place")
- ventana.config(width=400, height=800)
- # campo nombre
- etiqueta = ttk.Label(text="Nombre: ")
- etiqueta.place(x=160, y=120)
- caja_nombre = ttk.Entry()
- caja_nombre.place(x=220, y=120)
- # campo tel
- etiqueta = ttk.Label(text="Teléfono: ")
- etiqueta.place(x=160, y=160)
- caja_tel = ttk.Entry()
- caja_tel.place(x=220, y=160)
- # agrego un boton para guardar los datos
- boton = ttk.Button(text="Guardar", command=guardar_datos)
- boton.place(x=200, y=220, width=100, height=50)
- # lista (listbox)
- lista = tk.Listbox()
- lista.insert(0,"Python", "C++", "Java")
- lista.place(x=10, y=100)
- boton = ttk.Button(text="Seleccionar", command=listbox)
- boton.place(x=10, y=270)
- # 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.50)
- # lista desplegable (combobox)
- combo = ttk.Combobox(state="readonly",values=["VB","Go","C#","Erlang"])
- combo.place(x=10, y=300)
- boton = ttk.Button(text="Seleccionar", command=desplegable)
- boton.place(x=10, y=330)
- # casilla
- estado = tk.BooleanVar()
- estado.set("True")
- casilla = ttk.Checkbutton(text="Acepto las condiciones", variable=estado)
- casilla.place(x=10, y=380)
- # barra de progreso
- barra = ttk.Progressbar(maximum=100)
- barra.place(x=10, y=450, width=200)
- barra.step(50)
- barra.start(100)
- barra = ttk.Progressbar(orient=tk.VERTICAL)
- barra.place(x=300, y=450, height=200)
- barra.start(30)
- ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment