Is there an in depth ttk styling guide available? [closed]

为君一笑 提交于 2019-12-21 17:26:03

问题


So I've begun dabbling with Tkinter as of late, and I have it in my head to create what is essentially an application for storytelling. Ultimately, I'd like stylize most every widget used to conform with some overall aesthetic of my design.

Originally, I though I'd have to create most all of my application within tkinter's Canvas widget, as only it allowed for the level of customization I wanted. To my embarrassment, I have only just now stumbled across ttk and its ttk.Style methods.

As working with the Canvas widget will require me to reinvent some wheels: getting images to act as if they were buttons, drawing text on top of images when I could instead be using labels I'm curious as to whether ttk styling will save me doing more coding.

Is there an in depth tutorial out there for ttk styling?

Unfortunately, while there are more than a couple tutorials into using ttk.Style methods, none of them go into much detail as to what any style element does or what sort of data I'm supposed to pass into style.configure.

For example:

Let's say I want to change the default theme of ttk.Button (class name is TButton). I can figure out its layout components like so:

style.layout("TButton")

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

style.element_options("TButton.Label")

Which gives me a list much like: ('-space', '-emboss', '-image', '-background'). Playing around with 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 much of anything. I'm aware that some options don't do anything on certain OS, but isn't there a list somewhere of which ones work where? It's also possible that, to configure "-emboss" and other elements, I need to pass in a certain sort of data: like a list, a tuple or so on. I'd rather not sit here an guess until something works, and I'd rather not scour the internet for information on every individual element.

Surely there is some document somewhere that acts as a compendium for this information? If there isn't such a document, does anyone know how I can get a look at the default theme for any particular ttk widget and glean thereby what sort of data type I'm supposed to be plugging into my style.configure calls?

来源:https://stackoverflow.com/questions/17624309/is-there-an-in-depth-ttk-styling-guide-available

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!