I'm creating a program with Tkinter, It have 6 entry labels. I'm with difficulty to grid these labels in the center of page. I don't wanna to use .pack
How can I set the number of columns that the grid has? It seems tkinter ignore when I set column=6 for example.
here my code:
##Input 1 / Input de parametros
self.PwNomeLabel1 = Label(text = "Cliente:")
self.PwNomeLabel1["font"] = ("10")
self.PwNomeLabel1.grid(row=0,column=2,sticky=W)
self.inputpwtest1 = Entry(borderwidth= 2, validate='key')
self.inputpwtest1["width"] = 30
self.inputpwtest1.grid(row=0, column=3)
##Input 2
self.PwNomeLabel2 = Label(text = "Responsavel por Teste:")
self.PwNomeLabel2["font"] = ("10")
self.PwNomeLabel2.grid(row=1,column=2,sticky=W)
self.inputpwtest2 = Entry(borderwidth= 2, validate='key')
self.inputpwtest2["width"] = 30
self.inputpwtest2.grid(row=1, column=3)
##Input 3
self.PwNomeLabel3 = Label(text = "Nome do Sistema:")
self.PwNomeLabel3["font"] = ("10")
self.PwNomeLabel3.grid(row=2,column=2,sticky=W)
self.inputpwtest3 = Entry(borderwidth= 2, validate='key')
self.inputpwtest3["width"] = 30
self.inputpwtest3.grid(row=2,column=3)
##Input 4
self.PwNomeLabel4 = Label(text = "Ref:")
self.PwNomeLabel4["font"] = ("10")
self.PwNomeLabel4.grid(row=3,column=2,sticky=W)
self.inputpwtest4 = Entry(borderwidth= 2, validate='key')
self.inputpwtest4["width"] = 30
self.inputpwtest4.grid(row=3,column=3)
##Input 5
self.PwNomeLabel5 = Label(text = "Data Base:")
self.PwNomeLabel5["font"] = ("10")
self.PwNomeLabel5.grid(row=4,column=2,sticky=W)
self.inputpwtest5 = Entry(borderwidth= 2, validate='key')
self.inputpwtest5["width"] = 30
self.inputpwtest5.grid(row=4,column=3)
##Input 6
self.PwNomeLabel6 = Label(text = "Data Teste:")
self.PwNomeLabel6["font"] = ("10")
self.PwNomeLabel6.grid(row=5,column=2,sticky=W)
self.inputpwtest6 = Entry(borderwidth= 2, validate='key')
self.inputpwtest6["width"] = 30
self.inputpwtest6.grid(row=5,column=3)
root = Tk()
root.title("TEST PLATFORM")
Application(root)
root.geometry('1366x768')
root.mainloop()
In this way its results:
If I change label columns to "4" and "5" for the entry results:
Like the prints, It seems the Tkinter get confused and the grid stay desorganized


stickyandcolumnconfigure()are probably what you want. That said your question is not clear enough to provide a solid answer. What exactly is your goal? Do you want everything to be centered? Do you want things to be spaced out? What is the issue specifically? - Mike - SMTplace()however I thinkgrid()is still the correct choice you just need to learn how grid works. Here is a post I wrote to explain how grid works. Grid Manager - Mike - SMT