Python tkinter与标签问题对齐按钮



我想在这两个按钮下对齐第二个标签(蓝色文本((我在左侧对齐(,我尝试使用帧...或使用网格不知道该怎么做。这是图像屏幕截图,这是代码:

from tkinter import *
root = Tk()
root.title("Tema 1")
root.geometry("550x600")
first_frame = Frame(root)
first_frame.pack(side=TOP)
first_label = Label(first_frame, text = "Exercitiul 1",font = "Times 15 bold")
button_ex1_1 = Button(first_frame, text = "Enunt", font = "Times 12 italic", command = lambda: btn_ex1_1(l1),height = 1, width = 20)
button_ex1_2 = Button(first_frame, text = "Rezolvare", font = "Times 12 italic", command = lambda: btn_ex1_2(l1),height = 1, width = 20)
l1 = Label(first_frame, font="Times 13 bold", fg="blue" , wraplength = 550, width=55)
first_label.pack(side=TOP)
button_ex1_1.pack(side=LEFT)
button_ex1_2.pack(side=LEFT)
l1.pack(side=BOTTOM)

最简单的解决方案是在打包按钮之前打包蓝色标签。

first_label.pack(side=TOP)
l1.pack(side=BOTTOM)
button_ex1_1.pack(side=LEFT)
button_ex1_2.pack(side=LEFT)

包装器通过将小部件对准现有空白空间的一侧来工作。当您在左侧放一个小部件时,剩余的空白空间将是该小部件的右侧。因此,将事物放在首位,然后将事物放在底部,然后将事物放在中间。

最新更新