我想根据用户请求在运行时重新排列 PanedWindows 中的帧。以前我为每一帧指定了主控(这里是 pw1)。前任:
import Tkinter as tk
root = tk.Tk()
pw1 = tk.PanedWindow(orient=tk.HORIZONTAL, sashpad=2,
sashwidth=4, sashrelief=tk.RAISED)
pw1.pack(fill=tk.BOTH, expand=1)
frame1 = tk.Frame(pw1, bg='red',width=100, height=100)
frame2 = tk.Frame(pw1, bg ='yellow',width=100,height=100)
# This seems to do the same thing:
# frame1 = tk.Frame(bg='red',width=100, height=100) # vs. tk.Frame()
# frame2 = tk.Frame(bg ='yellow',width=100,height=100)
pw1.add(frame1, sticky=tk.NSEW)
pw1.add(frame2, sticky=tk.NSEW)
root.mainloop()
指定master有什么好处?