tkinter.Frame.grid


Definition
Position a widget in the parent widget in a grid.

Syntax
tkinter().Frame().grid()
Frame().grid()

Options
  • Frame(
  • column=number - use cell identified with given column (starting with 0)
  • columnspan=number - this widget will span several columns
  • in=master - use master to contain this widget
  • in_=master - see 'in' option description
  • ipadx=amount - add internal padding in x direction
  • ipady=amount - add internal padding in y direction
  • padx=amount - add padding in x direction
  • pady=amount - add padding in y direction
  • row=number - use cell identified with given row (starting with 0)
  • rowspan=number - this widget will span several rows
  • sticky=NSEW - if cell is larger on which sides will this widget stick to the cell boundary
  • )
Examples
tkinter.Frame.grid
The frame is adjusted in grid().
 from tkinter import*

master=Tk()
master.geometry("400x300")

frame1=Frame(master, width=200, height=150, background="Blue")
frame1.grid(row=0, column=0)

frame2=Frame(master, width=200, height=150, background="Red")
frame2.grid(row=1, column=0)

frame3=Frame(master, width=200, height=150, background="Green")
frame3.grid(row=0, column=1)

frame4=Frame(master, width=200, height=150, background="Yellow")
frame4.grid(row=1, column=1)

master.mainloop()






Comments