Advertisement
teslariu

widgets

Sep 4th, 2021
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.38 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. import tkinter as tk
  5. from tkinter import ttk
  6.  
  7. ventana = tk.Tk()
  8. ventana.title("Mi primera app")
  9. ventana.config(width=400, height=800)
  10.  
  11.  
  12. def seleccionar_lista():
  13.     seleccion = lista.get(lista.curselection())
  14.     print(seleccion)
  15.    
  16. def seleccionar_combo():
  17.     print(combo.get()) 
  18.  
  19.  
  20. # imagen dentro de una etiqueta
  21. mi_imagen = tk.PhotoImage(file="camion.png")
  22. label = ttk.Label(image=mi_imagen)
  23. label.place(relx=0.5, rely=0.5, relwidth=0.50, relheight=0.50)
  24.  
  25. # lista
  26. lista = tk.Listbox()
  27. lista.insert(0,"Python", "C", "Java")
  28. lista.place(x=10, y=100)
  29. boton = ttk.Button(text="Seleccionar", command=seleccionar_lista)
  30. boton.place(x=10, y=270)
  31.  
  32. # lista desplegable (combobox)
  33. combo = ttk.Combobox(state="readonly", values=["1   Bs As",2,3,4,5])
  34. combo.place(x=10, y=300)
  35. boton = ttk.Button(text="Seleccionar", command=seleccionar_combo)
  36. boton.place(x=10, y=330)
  37.  
  38. # casilla de verificación
  39. estado = tk.BooleanVar()
  40. estado.set("False")
  41. casilla = ttk.Checkbutton(text="Acepto los términos y condiciones", variable=estado)
  42. casilla.place(x=10, y=380)
  43.  
  44. # barra de progreso
  45. barra = ttk.Progressbar(maximum=100)
  46. barra.place(x=10, y=450, width=200)
  47. barra.step(99.9)
  48. barra.start(30)
  49.  
  50. barra = ttk.Progressbar(orient=tk.VERTICAL, maximum=100)
  51. barra.place(x=300, y=450, height=200)
  52. barra.step(99.9)
  53. barra.start(30)
  54.  
  55.  
  56. ventana.mainloop()
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement