一种简单的方法是使用
place图像作为背景图像。这是
place真正擅长做的事情。
例如:
background_image=tk.PhotoImage(...)background_label = tk.Label(parent, image=background_image)background_label.place(x=0, y=0, relwidth=1, relheight=1)
然后,您可以
grid或
pack在父母正常的其他部件。只要确保先创建背景标签,这样它的堆叠顺序就会降低。
注意:如果要在函数内部执行此操作,请确保保留对图像的引用,否则当函数返回时,图像将被垃圾收集器破坏。一种常见的技术是添加引用作为标签对象的属性:
background_label.image = background_image



