Advertisement
teslariu

place

Jan 4th, 2022
891
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.57 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. from pprint import pprint
  7.  
  8. def seleccion_listbox():
  9.     curso = lista.get(lista.curselection())
  10.     print(f"Curso elegido: {curso}")
  11.    
  12.    
  13. def seleccion_combo():
  14.     nombre = combobox.get()
  15.     print(f"Nombre elegido: {nombre}")
  16.  
  17. ventana = tk.Tk()
  18. ventana.title("Formulario")
  19. ventana.config(width=400, height=800)
  20. # si quiero que la ventana no se pueda modificar el tamaño
  21. # ventana.resizable(0,0)
  22.  
  23. # lista fija (listbox)
  24. lista = tk.Listbox()
  25. lista.insert(0,"Python", "Java", "C++", "Erlang","Ruby", "GO")
  26. lista.place(x=10,y=20)
  27. boton = ttk.Button(text="Seleccione una opcion", command=seleccion_listbox)
  28. boton.place(x=10, y=200)
  29.  
  30. # lista desplegable (combobox)
  31. combobox = ttk.Combobox(
  32.             state="readonly",
  33.             values=["Ana","Pedro","Oscar","Ines"],
  34.         )
  35. combobox.place(x=10, y=300)
  36. boton = ttk.Button(text="Seleccione un nombre", command=seleccion_combo)
  37. boton.place(x=10, y=330)
  38.  
  39. # imagen dentro de una etiqueta
  40. imagen = tk.PhotoImage(file="camion.png")
  41. etiqueta = ttk.Label(image = imagen)
  42. etiqueta.place(relx=0.5, rely=0.5, relwidth=0.5, relheight=0.5)
  43.  
  44. # casilla de verificacion
  45. estado = tk.BooleanVar()
  46. estado.set("True")
  47. casilla = ttk.Checkbutton(text="Acepto las condiciones", variable=estado)
  48. casilla.place(x=10, y=400)
  49.  
  50. # barra de progreso
  51. barra = ttk.Progressbar(maximum=100)
  52. barra.place(x=10, y=450, width=200)
  53. barra.step(10)
  54. barra.start(50)
  55.  
  56. barra = ttk.Progressbar(orient=tk.VERTICAL)
  57. barra.place(x=300, y=450, height=200)
  58. barra.start(50)
  59.  
  60.  
  61. ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement