I have a problem I'm having, which I don't know how to solve, due to my lack of knowledge. I'm trying to recreate the vertical scrollbar of the "Azure-ttk-theme" theme (given that the program will not be for commercial use, but for personal use). To help me out, I used "plastik_theme.py", and was mostly successful in translating it from Tcl to Python. There remains one last part to do, which I can't translate, because I can't find the same or similar examples around:
ttk::style element create Vertical.Scrollbar.thumb \
image [list $I(vert-accent) \
disabled $I(vert-basic) \
pressed $I(vert-hover) \
active $I(vert-hover) \
] -sticky ns
How should I write it in Python? Unfortunately, I haven't found anything around, even converters or similar. I have no desire to use the theme in question, just for scrollbar use, so what should I do? Thank you all
You can find an example of creating an element in the official tkinter documentation. Search that page for element_create
.
You will need to download the image files, create the images, and then create the element like this:
vert_accent_image = tk.PhotoImage(file="vert-accent.png")
vert_basic_image = tk.PhotoImage(file="vert-basic.png")
vert_hover_image = tk.PhotoImage(file="vert-hover.png")
style = ttk.Style(root)
style.element_create(
"Vertical.Scrollbar.thumb", "image",
vert_accent_image,
("disabled", vert_basic_image),
("pressed", vert_hover_image),
("active", vert_hover_image),
sticky="ns"
)
Make sure you keep a reference to the images, and of course adjust the filenames to point to wherever the images are.