Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- # Algunos widgets
- import tkinter as tk
- from tkinter import ttk
- from tkinter import messagebox
- def listado():
- seleccion = lista.get(lista.curselection())
- print(seleccion)
- def lista_combobox():
- print(combobox.get())
- ventana = tk.Tk()
- ventana.config(width=500, height=800)
- label = ttk.Label(text="Soy una etiqueta")
- label.place(x=30, y=50)
- # 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)
- # listbox
- lista = tk.Listbox()
- lista.insert(0,"Ana","Abel","Juana","Oscar")
- lista.place(x=10, y=100)
- boton = ttk.Button(text="Elegir", command=listado)
- boton.place(x=10, y=270)
- # lista desplegable
- combobox = ttk.Combobox(state="readonly", values=["C++","Java","Python"])
- combobox.place(x=10, y=300)
- boton = ttk.Button(text="Elegir", command=lista_combobox)
- boton.place(x=10, y=330)
- # casilla de verificacion
- 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(99.9)
- barra.start(75)
- barra = ttk.Progressbar(maximum=100, orient=tk.VERTICAL)
- barra.place(x=300, y=450, height=200)
- barra.step(25)
- barra.start(50)
- ##### cuadros de dialogo ###############
- # siempre retornan OK
- messagebox.showinfo(title="INFO",message="Apriete para continuar")
- messagebox.showwarning(title="OJO",message="¿Está seguro de lo que va a hacer?")
- messagebox.showerror(title="ERROR",message="JAJA.. dejá, no hagas nada")
- # retornan True or False
- respuesta = messagebox.askokcancel(title="Pregunta",message="¿Desea continuar")
- respuesta = messagebox.askyesno(title="DUDA",message="¿Sabe lo que está haciendo?")
- respuesta = messagebox.askretrycancel(title="AYUDA",message="Pruebe de nuevo")
- ventana.mainloop()
Add Comment
Please, Sign In to add comment