简体   繁体   English

如何更改 Tkinter Combobox 的布局?

[英]How to change the layout of a Tkinter Combobox?

To make the border disapear or simply change it's color.使边框消失或只是更改其颜色。 I tried with highlighttickness or borderwidth but it doesn't work.我尝试使用highlighttickness 或borderwidth,但它不起作用。 So I was told to try with the layouts, the thing is I don't know how to change the border with the layouts所以我被告知要尝试布局,问题是我不知道如何更改布局的边框

On this pic the border is still visible on the combobox I want to delete it or just change it's color在这张照片上,边框在 combobox 上仍然可见 我想删除它或只是改变它的颜色

PS: That's not a duplicate previous questions were deleted PS:那不是重复,之前的问题都被删了

测试

You can change the layout with the layout method of a style object.您可以使用 object 样式的layout方法更改布局。 It can take as an argument a new layout to replace the current layout.它可以将新布局作为参数来替换当前布局。

The following example illustrates how to remove the padding element around the checkbox, which I think might be the source of your light gray border:以下示例说明了如何删除复选框周围的填充元素,我认为这可能是浅灰色边框的来源:

style = ttk.Style()
layout = [
    ('Combobox.button', {
        'sticky': 'nswe',
        'children': [
                    ('Combobox.textarea', {
                        'sticky': 'nswe'
                    })
                ]
            })
]
style.layout("TCombobox", layout)

Changing styles and style layouts is unfortunately an under-documented feature of tkinter.不幸的是,更改 styles 和样式布局是 tkinter 的一个未充分记录的功能。 However, there are several resources on the internet you might find useful:但是,您可能会发现 Internet 上有一些有用的资源:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM