如何填充OptionMenu的区域 - tkinter

发布于 2025-01-11 23:29:39 字数 622 浏览 2 评论 0原文

我想用灰色填充窗口,但是在选项菜单周围有一个未填充的缺失区域。

例如:让我们使用一个简单的代码来检查我的问题是什么。

from tkinter import *
master = Tk()
master.config(bg="grey")
variable = StringVar(master)
variable.set("hello")
w = OptionMenu(master, variable, "hello1", "hello2")
w.config(bg="grey")
w.pack()
mainloop()

这是结果:

在此处输入图像描述

我真的不知道如何去掉(填充)白色部分。

输入图片此处描述

I want to fill the window with grey, however around the OptionMenu there is a missing area which isn't filled.

For example: let's take a simple code that will examine what is my problem.

from tkinter import *
master = Tk()
master.config(bg="grey")
variable = StringVar(master)
variable.set("hello")
w = OptionMenu(master, variable, "hello1", "hello2")
w.config(bg="grey")
w.pack()
mainloop()

and this is the result:

enter image description here

I really don't know how to get rid (fill) of the white part.

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忱杏 2025-01-18 23:29:39

highlightthickness = 0 添加到 w.config 行将删除边框,但小部件仍会显示为凸起。如果您想让它完全平坦,您还可以添加 relief = FLAT

Adding highlightthickness = 0 to your w.config line will remove the border, but the widget will still appear raised. If you would like to make it totally flat you can also add relief = FLAT

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文