Where are tk style customization saved/stored?

Viewed 102

Take this very simple code sample

import tkinter as tk
from tkinter import ttk

root = tk.Tk()

s = ttk.Style()
s.theme_use('vista')
s.map("Mod.TCombobox",fieldbackground=[('readonly', 'red')])

Can you tell me where the Mod.TCombobox custom style is saved or stored? I mean, is there a way to retrieve the list of all defined style options available? (Both 'standard' and 'custom' ones possibly)

I tried looking on official documentation but I can't seem to find an answer to this.

Thank you in advance for your support

(P.S. I tried having a look at s.element_names() but, no surprise, it isn't there...)

EDIT:

To clarify a little, in first place, I'm not asking for the list of themes available (I know that can be obtained using the command s.theme_names()).

That said, suppose I define a new rule now, like for instance:

s.map("Mod.TEntry",fieldbackground=[('readonly', 'red')])

What I'm asking is: is there a command or any way for me to retrieve a list of custom defined tk style rules, such as ['Mod.TCombobox', 'Mod.TEntry'] in this case? (Whenever possible, I'd settle even for a listing with both custom and non-custom style rules definitions, having my custom defined styles mixed among/together with "standard" ones, such as 'TCombobox', 'TEntry', etc...)

In the same way, when using the style layout command, like for instance:

s.layout('MyCustomTCB', s.layout('TCombobox'))

As second part of the question: where or how can I retrieve a list containing all the custom style layout I created?

(P.S. Even I'm not asking that here, I want to thank Bryan Oakley that provided me the link to ttk library source code which, for sure, can be very useful to look at for what concerns with standard built-in tk themes style rules and layout.)

1 Answers

The answer to your title Where are tk style customization saved/stored? is written in TIP 48 and it is stated the:

Current implementation uses thread-local storage for holding dynamic data. Since most data is not thread-specific, this could be changed to a more memory-efficient scheme.

To address your other question if it is possible to retrieve a list of defined styles. I did not find a obvious way to do so, neither in the defined methods out of the TIP 48, or the style manual page, nor does the source code indicate such a list.

Related