Home > Software engineering >  In Tkinter The grid method when using on an input is not working.Why?
In Tkinter The grid method when using on an input is not working.Why?

Time:01-02

I want the input to be somewhere in the bottom of the screen but when I am using the grid method the position on the input is not changing.Why?

# Import module
from tkinter import *

# Create object
root = Tk()

# Adjust size
root.geometry( "5000x5000" )

e1 = Entry(root)
e1.grid(row=10, column=1,sticky=W)

# Execute tkinter
root.mainloop()

CodePudding user response:

Grid rows only have any height or width if you have widgets in them Therefore your first 10 rows have a pixel height of 0, causing row 10 to be placed on y = 0.
By setting the column weight to a non zero value, and setting the sticky to S you can pin the widget to the bottom of the root container:

# Import module
from tkinter import Tk, Entry

# Create object
root = Tk()

# Adjust size
root.geometry("500x500")

root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)

e1 = Entry(root)
e1.grid(row=0, column=0, sticky="S")

# Execute tkinter
root.mainloop()
  • Related