2d table of input fields : Layout « Tkinker « Python Tutorial






2d table of input fields
from Tkinter import *
     
rows = []
for i in range(5):
    cols = []
    for j in range(4):
        e = Entry(relief=RIDGE)
        e.grid(row=i, column=j, sticky=NSEW)
        e.insert(END, '%d.%d' % (i, j))
        cols.append(e)
    rows.append(cols)
     
def onPress():
    for row in rows:
        for col in row:
            print col.get(),
        print
     
Button(text='Fetch', command=onPress).grid()
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