Python Tkinter:OptionMenu 修改下拉列表宽度 [英] Python Tkinter: OptionMenu modify dropdown list width

查看:39
本文介绍了Python Tkinter:OptionMenu 修改下拉列表宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从 Tkinter 创建了一个列跨度为 2 的 OptionMenu.但是,下拉列表/菜单与宽度不匹配,因此看起来不太好.知道如何匹配它们的宽度吗?

self.widgetVar = StringVar(self.top)选择 = ['', 'wire', 'register']typeOption = OptionMenu(self.top, self.widgetVar, *choices)typeOption.grid(column = 0, columnspan = 2, row = 0,sticky = 'NSWE', padx = 5, pady = 5)

解决方案

没有办法改变下拉菜单的宽度.

您可能需要考虑 ttk.Combobox 小部件.它具有不同的外观,可能正是您正在寻找的.

I have created an OptionMenu from Tkinter with a columnspan of 2. However, the dropdown list/menu does not match the width, so it does not look good. Any idea on how to match their width?

self.widgetVar = StringVar(self.top)
choices = ['', 'wire', 'register']
typeOption = OptionMenu(self.top, self.widgetVar, *choices)
typeOption.grid(column = 0, columnspan = 2, row = 0, sticky = 'NSWE', padx = 5, pady = 5)

解决方案

There is no way to change the width of the dropdown.

You might want to consider the ttk.Combobox widget. It has a different look that might be what you're looking for.

这篇关于Python Tkinter:OptionMenu 修改下拉列表宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆