Advertisement
teslariu

pl

Jul 20th, 2021
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.96 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4.  
  5. import tkinter as tk
  6. from tkinter import ttk
  7.  
  8. def saludar():
  9.     nombre = caja_nombre.get()
  10.     print(f"Hola {nombre}")
  11.    
  12. def imprimir_lista():
  13.     seleccion = lista.get(lista.curselection())
  14.     print(seleccion)
  15.    
  16. def imprimir_combo():
  17.     seleccion = combo.get()
  18.     print(seleccion)
  19.    
  20.    
  21.  
  22. ventana = tk.Tk()
  23. ventana.title("Posicionamiento place")
  24. ventana.config(width=400, height=800)
  25.  
  26. # evito que alguien cambie el tamaño de la ventana
  27. # ventana.resizable(0,0)
  28.  
  29. boton = ttk.Button(text="Saludar", command=saludar)
  30. boton.place(x=50, y=10, width=100, height=40)
  31.  
  32. caja_nombre = ttk.Entry()
  33. caja_nombre.place(x=200, y=10)
  34. caja_nombre.insert(0, "Ej: Juan Perez")
  35.  
  36. etiqueta = ttk.Label(text="Ingrese su nombre")
  37. etiqueta.place(x=210, y=40)
  38.  
  39. # imagen dentro de una etiqueta
  40. imagen = tk.PhotoImage(file='camion.png')
  41. label = ttk.Label(image=imagen)
  42. label.place(relx=0.5, rely=0.5, relwidth=0.5, relheight=0.5)
  43.  
  44. # lista (listbox)
  45. lista = tk.Listbox()
  46. lista.insert(0,"Python","Java","C++","Go")
  47. lista.place(x=10, y=100)
  48. boton = ttk.Button(text="Guardar selección", command=imprimir_lista)
  49. boton.place(x=10, y=250)
  50.  
  51. # lista desplegable (combobox)
  52. combo = ttk.Combobox(state="readonly",
  53.                     values=[
  54.                             "Visual Basic",
  55.                             "Erlang",
  56.                             "R",
  57.                             "JavaScript"
  58.                             ]
  59.                     )
  60. combo.place(x=10, y=300)
  61. boton = ttk.Button(text="Guardar selección", command=imprimir_combo)
  62. boton.place(x=10, y=330)
  63.  
  64. # casilla de verificacion
  65. estado = tk.BooleanVar()
  66. estado.set("True")
  67. casilla = ttk.Checkbutton(text="Aceptar las condiciones", variable=estado)
  68. casilla.place(x=10, y=380)
  69.  
  70. # barra de progreso
  71. barra = ttk.Progressbar(maximum=100, orient=tk.VERTICAL)
  72. barra.place(x=10, y=450, height=200)
  73. barra.step(30)
  74. barra.start(10)
  75.  
  76.  
  77. ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement