# coding=gbk
# Frame 是一个在 Windows 上分离小区域的部件, 它能将 Windows 分成不同的区,然后存放不同的其他部件.
# 同时一个 Frame 上也能再分成两个 Frame, Frame 可以认为是一种容器.
# 运行结果:https://s1.ax1x.com/2018/04/16/CeXs6s.jpg
import tkinter as tk
window = tk.Tk()
window.title('my window')
window.geometry('200x200')
tk.Label(window, text='on the window').pack()
frm = tk.Frame(window)
frm.pack()
###在刚刚创建的`frame`上创建两个`frame`,我们可以把它理解成一个大容器里套了一个小容器,
# 即`frm`上有两个`frame` ,`frm_l`和`frm_r`
frm_l = tk.Frame(frm)
frm_r = tk.Frame(frm)
###这里是控制小的`frm`部件在大的`frm`的相对位置,
# 此处`frm_l`就是在`frm`的左边,`frm_r`在`frm`的右边
frm_l.pack(side='left')
frm_r.pack(side='right')
###这里的三个label就是在我们创建的frame上定义的label部件,还是以容器理解,
# 就是容器上贴了标签,来指明这个是什么,解释这个容器。
tk.Label(frm_l, text='on the frm_l1').pack()##这个`label`长在`frm_l`上,显示为`on the frm_l1`
tk.Label(frm_l, text='on the frm_l2').pack()##这个`label`长在`frm_l`上,显示为`on the frm_l2`
tk.Label(frm_r, text='on the frm_r1').pack()##这个`label`长在`frm_r`上,显示为`on the frm_r1`
tk.Label(frm_r, text='on the frm_r2').pack()##这个`label`长在`frm_r`上,显示为`on the frm_r2`
window.mainloop()