How it works...

Building ttk.Style for our applications is quite straightforward—we only need to create an instance with our parent widget as its first parameter.

Then, we can set the default styling options for our themed widgets, using an uppercase T plus the widget name: TButton for ttk.Button, TLabel for ttk.Label, and so on. However, there are some exceptions, so it is recommended that you check on the Python interpreter the classname by calling the winfo_class() method on the widget instance.

We can also add a prefix to identify a style that we do not want to use by default, but explicitly set it to some specific widgets:

        style.configure("My.TLabel", padding=10)
# ...
label = ttk.Label(master, text="Some text", style="My.TLabel")
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset