Add equivalent pack window : Pack « Tkinker « Python Tutorial






Add equivalent pack window
from Tkinter import *
colors = ['red', 'green', 'yellow', 'orange', 'blue', 'navy']
     
def gridbox(parent):
    r = 0
    for c in colors:
        l = Label(parent, text=c, relief=RIDGE,  width=25)
        e = Entry(parent, bg=c,   relief=SUNKEN, width=50)
        l.grid(row=r, column=0)
        e.grid(row=r, column=1)
        r = r+1
     
def packbox(parent):
    for c in colors:
        f = Frame(parent)
        l = Label(f, text=c, relief=RIDGE,  width=25)
        e = Entry(f, bg=c,   relief=SUNKEN, width=50)
        f.pack(side=TOP)
        l.pack(side=LEFT)
        e.pack(side=RIGHT)

root = Tk()
gridbox(Toplevel())
packbox(Toplevel())
Button(root, text='Quit', command=root.quit).pack()
mainloop()








18.23.Pack
18.23.1.Pack control to the topPack control to the top
18.23.2.Pack a framePack a frame
18.23.3.pack(expand=YES, fill=BOTH)pack(expand=YES, fill=BOTH)
18.23.4.Set control's properties through dictionary syntaxSet control's properties through dictionary syntax
18.23.5.Frame Widgets and CenteringFrame Widgets and Centering
18.23.6.Pack control to Top, left and rightPack control to Top, left and right
18.23.7.Add equivalent pack windowAdd equivalent pack window
18.23.8.Add label and resizingAdd label and resizing