简体   繁体   中英

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. 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

PS: That's not a duplicate previous questions were deleted

测试

You can change the layout with the layout method of a style object. 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. However, there are several resources on the internet you might find useful:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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