I've been working on a welcome window for my app and I can't seem to get the LabelFrames on the last row together on the window. I've tried configuring the column weight
, by adding padx
and by eliminating the columnspan
, buth nothing seems to work and the LabelFrame
widgets keep the same distance.
The Frame
has grid
packing and in the last row
the LabelFrames
are placed.
Here's my code:
import tkinter as tk
import tkinter.font as tkf
class ventana_inicio(tk.Frame):
def __init__(self,parent,controller,dbs):
tk.Frame.__init__(self,controller)
self.pack()
self.controller=controller
self.db_state=dbs
lblmuc=tk.Label(self,text="MAMOOTS ULTIMATE CLUB",font=tkf.Font(family="Arial Black",size="20"))
lbl98=tk.Label(self,text="Alive since 1998",font=tkf.Font(family="Segoe Script",slant="italic"))
lblbla=tk.Label(self,text="Version 1.0 // 2020",font=tkf.Font(family="Arial Black",size="8"),width=20)
lbfDB=tk.LabelFrame(self,text="SQL")
btnIDB=tk.Button(lbfDB,text="Iniciar")
btnCDB=tk.Button(lbfDB,text="Cargar")
btnBDB=tk.Button(lbfDB,text="Borrar")
lbfinf=tk.LabelFrame(self,text="Aplicación")
btnIAP=tk.Button(lbfinf,text="Iniciar")
btnLAP=tk.Button(lbfinf,text="Ver Log")
lfbst=tk.LabelFrame(self,text="Estado")
btnst=tk.Button(lfbst,text="Revisar")
lblmuc.grid(row=0,column=0,columnspan=6)
lbl98.grid(row=1,column=0,columnspan=6)
lblbla.grid(row=2,column=0,columnspan=6)
lbfDB.grid(row=3,column=0,columnspan=3,padx=5)
lbfinf.grid(row=3,column=3,columnspan=2,padx=5)
lfbst.grid(row=3,column=5,padx=5)
btnIDB.grid(row=0,column=0)
btnCDB.grid(row=0,column=1)
btnBDB.grid(row=0,column=2)
btnIAP.grid(row=0,column=0)
btnLAP.grid(row=0,column=1)
btnst.grid(row=0,column=0)
You need to use the sticky
attribute to tell each labelframe to "stick" to the edges of the space they have been given.
lbfDB.grid(row=3,column=0,columnspan=3,padx=sticky="ew")
lbfinf.grid(row=3,column=3,columnspan=2,padx=5, sticky="ew")
lfbst.grid(row=3,column=5,padx=5, sticky="ew")