Frame 容器分组

51.8 Frame 容器分组

Frame 把相关控件分组,便于布局和加边框 padding。

上下两个区域

# ========================================
# 示例:Frame 分区
# 说明:不同 Frame 内分别 pack
# ========================================
import tkinter as tk

root = tk.Tk()
top = tk.Frame(root, bg='#eef', padx=10, pady=10)
bottom = tk.Frame(root, bg='#efe', padx=10, pady=10)
top.pack(fill='x')
bottom.pack(fill='x')
tk.Label(top, text='上方区域', bg='#eef').pack()
tk.Label(bottom, text='下方区域', bg='#efe').pack()
root.mainloop()