打包以填满各个方向。根据需要添加填充。
或者,使用允许您使用相对或绝对定位的位置。您可以使用.5 / .5的相对x / y和“ c”的锚点(中心)。
import Tkinter as tkroot=tk.Tk()f1 = tk.frame(width=200, height=200, background="red")f2 = tk.frame(width=100, height=100, background="blue")f1.pack(fill="both", expand=True, padx=20, pady=20)f2.place(in_=f1, anchor="c", relx=.5, rely=.5)root.mainloop()



