Advertisement
teslariu

ejemplos

Oct 9th, 2021
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.50 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # script que implementa un formulario
  5.  
  6. import tkinter as tk
  7. from tkinter import ttk
  8.  
  9. def seleccionar_lista():
  10.     valor = lista.get(lista.curselection())
  11.     print(valor)
  12.    
  13. def seleccionar_combo():
  14.     valor = combo.get()
  15.     print(valor)
  16.  
  17.  
  18. ventana = tk.Tk()
  19. ventana.title("mi ventana")
  20. ventana.config(width=400, height=600)
  21.  
  22. # lista (listbox)
  23. lista = tk.Listbox()
  24. lista.insert(0,"Ale","Juana","Ana","Tito","Luisa")
  25. lista.place(x=10, y=20)
  26. boton = ttk.Button(text="Seleccionar", command=seleccionar_lista)
  27. boton.place(x=10, y=200)
  28.  
  29. # lista desplegable(combobox)
  30. combo = ttk.Combobox(state="readonly", values=["Ale","Juana","Ana","Tito","Luisa"])
  31. combo.place(x=10, y=250)
  32. boton = ttk.Button(text="Seleccionar", command=seleccionar_combo)
  33. boton.place(x=10, y=280)
  34.  
  35. # casilla de verificación
  36. estado = tk.BooleanVar()
  37. estado.set("True")
  38. casilla = ttk.Checkbutton(text="Acepto las condiciones", variable=estado)
  39. casilla.place(x=250, y=30)
  40.  
  41. # imagen (dentro de una etiqueta)
  42. imagen = tk.PhotoImage(file="Imagen1.png")
  43. etiqueta = ttk.Label(image=imagen)
  44. etiqueta.place(relx=0.50, rely=0.50, relwidth=0.50, relheight=0.50)
  45.  
  46.  
  47. # barra de progreso
  48. barra = ttk.Progressbar(maximum=100)
  49. barra.place(x=10, y=350, width=200)
  50. # barra.step(99.9) toda la barra completa
  51. barra.start(10)
  52.  
  53. barra = ttk.Progressbar(maximum=100, orient=tk.VERTICAL)
  54. barra.place(x=250, y=350, height=200)
  55. # barra.step(99.9) toda la barra completa
  56. barra.start(10)
  57.  
  58. ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement