please help to fix the script.
from tkinter import * colors = ['red', 'white', 'blue'] def packbox(root): Label(root, text='Pack').pack() for color in colors: row = Frame(root) lab = Label(row, text=color, relief=RIDGE, width=25) ent = Entry(row, bg=color, relief=SUNKEN, width=50) row.pack(side=TOP, expand=YES, fill=BOTH) lab.pack(side=LEFT, expand=YES, fill=BOTH) ent.pack(side=RIGHT, expand=YES, fill=BOTH) root = Tk() packbox(root) mainloop()
I would like to align the text in the Label widget on the left edge
Advertisement
Answer
Try this
Label(root, text='Pack', anchor='w').pack(fill='both')