How to left justify Python tkinter grid columns while filling entire cell How to left justify Python tkinter grid columns while filling entire cell tkinter tkinter

How to left justify Python tkinter grid columns while filling entire cell


For any grid of geometry, add option sticky="W", for example,

self.tableDataFrame.grid(sticky="W", row=0, column=0)


If you want the text in a label to be left-aligned, use the anchor option. It takes a string representing a point on a compass (eg: "w" = "west", meaning the text is anchored to the left):

for col in row:    Label(..., anchor="w").grid(...)


You are not defining the width of your label so tkinter sets the width of Label equal to the width of the text. Thats why your labels do not occupy entire width of the cell. To make them occupy all the available width use stickey = E+W

    Label(self.tableDataFrame,text=col,font=tableHeaderFont,bg=self.headerBG,fg=self.headerFG,highlightbackground=self.borderColor,highlightthickness=1).grid(row=1,column=colCount,sticky=W+E, ipady=2, ipadx=5)