Advertisement
teslariu

grid

Sep 7th, 2022
1,013
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # GRID
  4.  
  5. import tkinter as tk
  6. from tkinter import ttk
  7.  
  8. ventana = tk.Tk()
  9. ventana.title("grid")
  10. ventana.config(width=400, height=300)
  11.  
  12. caja = ttk.Entry()
  13. caja.grid(row=0, column=0)
  14. boton = ttk.Button(text="HOLA")
  15. boton.grid(row=0,column=1)
  16. etiqueta = ttk.Label(text="HOLA A TODOS")
  17. #etiqueta.grid(row=1,column=0)
  18.  
  19. # expando la etiqueta a dos columnas
  20. etiqueta.grid(row=1,column=0, columnspan=2)
  21.  
  22. # voy a expandir la columna 0
  23. ventana.columnconfigure(0, weight=1)
  24.  
  25. # voy a expandir la fila 1
  26. ventana.rowconfigure(1, weight=1)
  27.  
  28. # anclar la etiqueta
  29. etiqueta.grid(row=1,column=0, columnspan=2, sticky="w")
  30.  
  31. # voy a expandir la fila 0
  32. ventana.rowconfigure(0, weight=1)
  33.  
  34. # voy a expandir por direcciones a la caja de texto
  35. caja.grid(row=0, column=0, sticky="nswe")
  36.  
  37. # voy a espaciar la expansión
  38. caja.grid(row=0, column=0, sticky="nswe", padx=10, pady=50)
  39.  
  40.  
  41. ventana.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement