我可以设置主窗口的背景,我不需要担心窗口试图适应背景图像,或者图像将小部件推开。
然而,当我试图用一个框架做同样的事情时,它变成了一个巨大的混乱。。。
我已经尝试了一些事情,但一切都与调整图像本身有关,我不想扭曲图像。我希望图像在框架中,而不是调整框架大小以适应图像。
有没有一种方法可以在不改变帧大小的情况下将图像放入帧的背景中?
编辑:注意:我使用的图像足够大,可以填满屏幕,所以如果用户正在调整大小,图像将覆盖所有额外的空间。
这就是我如何在主窗口中添加背景图像:
bgImage=PhotoImage(file="./Colors/bgImage.png")
bgLable = Label(root,image = bgImage)
bgLable.image = bgImage
bgLable.grid(row=0,column=0,columnspan=3,rowspan=8)
但是,当我尝试对帧执行相同的操作时,它也会调整帧的大小:
^{pr2}$我还尝试了其他一些方法,但它们会扭曲图像以适合窗口/框架,我不想扭曲图像。
编辑:
我找到了一份工作。我需要使用我的小部件,而不是我的小部件。侧菜单小部件不在窗口的左上角,所以我尝试使用框架来解决问题(现在使用.place)。框架可以工作,但我找不到一种方法使框架透明,这样我可以保持我的背景从我的根窗口。这就是为什么我一直试图在我的框架中添加背景图像,但是没有调整框架大小以适应图像。
是的。将
place
与相对坐标一起使用。下面将把标签和您的图像放在根窗口的中心,并且不会影响任何其他小部件。在这是我认为}的少数几次之一。这是官方文件所说的
place
优于使用grid
或{place
:相关问题 更多 >
编程相关推荐