如何填充OptionMenu的区域 - tkinter
我想用灰色填充窗口,但是在选项菜单周围有一个未填充的缺失区域。
例如:让我们使用一个简单的代码来检查我的问题是什么。
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:
I really don't know how to get rid (fill) of the white part.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
highlightthickness = 0
添加到w.config
行将删除边框,但小部件仍会显示为凸起。如果您想让它完全平坦,您还可以添加relief = FLAT
Adding
highlightthickness = 0
to yourw.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 addrelief = FLAT