ttkwidgets icon indicating copy to clipboard operation
ttkwidgets copied to clipboard

ttkwidgets.CheckboxTreeview can't appear background color on selected items.

Open water5 opened this issue 5 years ago • 1 comments

This's use ttkwidgets.CheckboxTreeview: Image

this's use ttk.Treeview: Image

water5 avatar Jan 02 '21 19:01 water5

This is actually not unexpected behaviour. CheckboxTreeview uses a custom style named Checkbox.Treeview, which you'll have to modify yourself if you want this behaviour. If you were to use ttkthemes, for example:

root = ThemedTk(theme="plastik")

tree = CheckboxTreeview(root)
style = ttk.Style(root)
style.map("Checkbox.Treeview",
    background=[
        ("disabled", "#E6E6E6"),
        ("selected", style.lookup("Treeview", "background", ("selected",)))
    ])
tree.pack()

You can modify this snippet for doing this for all states you want to mimic. There's an argument to be made here for implementing this as the default behaviour, but then there's the problem of this custom style not updating after theme change (so if you create the Treeview first and then set the theme for your application, it's not going to work). So overall, for now I advise you to do it in this explicit manner.

RedFantom avatar Feb 01 '21 11:02 RedFantom