【发布时间】:2019-03-16 07:07:34
【问题描述】:
import tkinter as tk
root = tk.Tk()
root.title("window")
yellow_header = tk.Label(root, text = 'Header', bg = 'light yellow')
yellow_header.pack(side = tk.TOP, anchor = tk.N, expand = 1, fill = tk.X)
yellow_header2 = tk.Label(root, text = 'paragraph', bg = 'light yellow')
yellow_header2.pack(side = tk.TOP, anchor = tk.N, expand = 1, fill = tk.X)
root.mainloop()
对于上面的代码,我试图将这两个标签都固定在顶部并直接位于彼此下方。虽然第一个标签 (yellow_header) 锚定在顶部,但第二个标签 (yellow_header2) 在展开时向中心移动。我该如何解决这个问题?
提前谢谢你!
【问题讨论】:
标签: python user-interface tkinter