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
- from tkinter import messagebox
- def imprimir_listbox():
- seleccion = lista.get(lista.curselection())
- print(seleccion)
- def imprimir_combo():
- seleccion = combo.get()
- print(seleccion)
- ventana = tk.Tk()
- ventana.title("Posicionamiento place")
- ventana.config(width=400, height=800)
- # etiquetas
- label = ttk.Label(text="Hola")
- label.place(x=160, y=120)
- # imagen dentro de etiqueta
- imagen = tk.PhotoImage(file="camion2.png")
- label = ttk.Label(image=imagen)
- label.place(relx=0.5, rely=0.5, relwidth=0.5, relheight=0.5)
- # lista (listbox)
- lista = tk.Listbox()
- lista.insert(0, "Python","C","Java","Go")
- lista.place(x=10, y=100)
- boton = ttk.Button(text="Seleccionar", command=imprimir_listbox)
- boton.place(x=10, y=270)
- # lista desplegable (combobox)
- combo = ttk.Combobox(state="readonly",
- values=("Juan","Pedro","Ana")
- )
- combo.place(x=10, y=300)
- boton = ttk.Button(text="Seleccionar", command=imprimir_combo)
- boton.place(x=10, y=330)
- # casilla de verificación
- estado = tk.BooleanVar()
- estado.set("False")
- casilla = ttk.Checkbutton(text="Acepto términos y 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(10)
- barra.start(70)
- barra = ttk.Progressbar(maximum=100, orient=tk.VERTICAL)
- barra.place(x=300, y=450, height=200)
- barra.step(10)
- barra.start(70)
- # cuadros de dialogo
- # siempre retornan True
- messagebox.showinfo(title="OJITO", message="Fijate bien lo que haces...")
- messagebox.showwarning(title="ESPERA", message="No hagas macanaas...")
- messagebox.showerror(title="FUISTE", message="Estas al horno...")
- # Retornan True of False
- eleccion1 = messagebox.askokcancel(title="Pregunta", message="¿Seguimos?")
- eleccion2 = messagebox.askyesno(title="Backup", message="Iniciar copia de respaldo")
- eleccion3 = messagebox.askretrycancel(title="error", message="Probar de nuevo")
- ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment