在 python 2.7 中,我试图对齐文本 frankie anne,使其靠近名称按钮和 27,因此它靠近年龄按钮只能使它们居中。试过左下角已经不行了。任何帮助都会有所帮助。
from Tkinter import *
root = Tk()
toolbar = Frame(root)
b = Button(toolbar, text="Home", width=9)
b.pack(side=LEFT, padx=2, pady=2)
b = Button(toolbar, text="About-us", width=9)
b.pack(side=LEFT, padx=2, pady=2)
b = Button(toolbar, text="Contact-us", width=9)
b.pack(side=LEFT, padx=2, pady=2)
b = Button(toolbar, text="Travelling", width=9)
b.pack(side=LEFT, padx=2, pady=2)
toolbar.pack(side=TOP, fill=X)
o = Label(root,text="Frank Anne",font =("Italic",18,"bold"))
o.pack()
toolbar1 = Frame(root)
b = Button(toolbar1, text="Name",width=9)
b.pack(side=LEFT, padx=2, pady=2)
o = Label(root,text="27",font =("Italic",10,"bold"))
o.pack()
o = Label(root,text="Frankie anne",font =("Italic",10,"bold"))
o.pack(side=TOP, padx=0, pady=0)
toolbar1.pack(side=BOTTOM, fill=X)
toolbar2 = Frame(root)
b = Button(toolbar2, text="Age",width=9)
b.pack(side=LEFT, padx=2, pady=2)
b.pack(side=BOTTOM, padx=2, pady=2)
toolbar2.pack(side=BOTTOM, fill=X)
mainloop()