Is there a ttk style guide available?

So, I started Tkinter lately, and I have in my head to create what is essentially a storytelling application. Ultimately, I would like to stylize most of the widget that would match some general aesthetics of my design.

Initially, although I would have to create most of my entire application in tkinter Canvas widgets, as this allowed only for the level of customization that I wanted. To my embarrassment, I just stumbled upon ttk and its ttk.Style methods.

Since working with Canvas widgets will require me to rethink a few wheels: make the images act as if they were buttons, drawing text on top of the images when I could use shortcuts instead. I am curious if the ttk style will save me by doing more coding.

Is there an in-depth tutorial for ttk styling?

Unfortunately, although there are more than a few tutorials in using ttk.Style methods, none of them contain detailed information about what a style element does or what data I should pass to style.configure.

For instance:

Let's say I want to change the default theme ttk.Button (TButton class name). I can find the build components like this:

style.layout("TButton") 

This gives me: TButton.TButton, TButton.Focus, TButton.Padding and TButton.Label. From here I can determine which style elements of these layout components can be changed:

 style.element_options("TButton.Label") 

This gives me a list similar to: ('-space', '-emboss', '-image', '-background'). Playing with the configure method, I can figure out how to change the "-image" and "-background" elements:

 style.configure("TButton", background = "BLACK") 

but I can't seem to get some options like "-emboss" to do something. I know that some options do nothing on a particular OS, but is there a list of where they work? It is also possible that in order to configure "-emboss" and other elements, I need to pass certain data: for example, a list, a tuple, or so on. I would rather not sit here guessing until something works, and I would prefer not to search the Internet for information about each individual item.

Of course, is there some kind of document somewhere that acts as a compendium for this information? If there is no such document, does anyone know how I can look at the default theme for any particular ttk and glean widget, thereby what data type should I connect to my style.configure calls?

+4
source share

Source: https://habr.com/ru/post/1491203/


All Articles