Grid layout : Layout « Tkinker « Python Tutorial






Grid layout
from Tkinter import *
root = Tk()

Label(root, text="Last Name:").grid(row=0, sticky=W)
Label(root, text="First Name:").grid(row=1, sticky=W)
Label(root, text="Phone #:").grid(row=2, sticky=W)
Label(root, text="email:").grid(row=3, sticky=W)
entry_ln = Entry(root)
entry_fn = Entry(root)
entry_ph = Entry(root)
entry_em = Entry(root)

entry_ln.grid(row=0, column=1)
entry_fn.grid(row=1, column=1)
entry_ph.grid(row=2, column=1)
entry_em.grid(row=3, column=1)
Label(root).grid(row=4, sticky=W)
Label(root, text="Skill set summary:").grid(row=5, sticky=W)
cb_gender = Checkbutton(root, text="Python")
cb_gender.grid(row=6, sticky=W)
cb_gender = Checkbutton(root, text="Perl")
cb_gender.grid(row=7, sticky=W)
b_apply = Button(root, text="Apply")
b_apply.grid(row=7, column = 1)
root.mainloop()








18.18.Layout
18.18.1.Pack to TOP and RIGHTPack to TOP and RIGHT
18.18.2.Grid layoutGrid layout
18.18.3.Pack leftPack left
18.18.4.Pack layout manager demonstration.Pack layout manager demonstration.
18.18.5.Grid layout manager demonstration.Grid layout manager demonstration.
18.18.6.Demonstrates text and entry widgets, and the grid layout managerDemonstrates text and entry widgets, and the grid layout manager
18.18.7.Simple 2d tableSimple 2d table
18.18.8.2d table of input fields2d table of input fields