MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _script_from_settings

Function _script_from_settings

tools/python-3.11.9-amd64/Lib/tkinter/ttk.py:182–222  ·  view source on GitHub ↗

Returns an appropriate script, based on settings, according to theme_settings definition to be used by theme_settings and theme_create.

(settings)

Source from the content-addressed store, hash-verified

180 return '\n'.join(script), indent
181
182def _script_from_settings(settings):
183 """Returns an appropriate script, based on settings, according to
184 theme_settings definition to be used by theme_settings and
185 theme_create."""
186 script = []
187 # a script will be generated according to settings passed, which
188 # will then be evaluated by Tcl
189 for name, opts in settings.items():
190 # will format specific keys according to Tcl code
191 if opts.get('configure'): # format 'configure'
192 s = ' '.join(_format_optdict(opts['configure'], True))
193 script.append("ttk::style configure %s %s;" % (name, s))
194
195 if opts.get('map'): # format 'map'
196 s = ' '.join(_format_mapdict(opts['map'], True))
197 script.append("ttk::style map %s %s;" % (name, s))
198
199 if 'layout' in opts: # format 'layout' which may be empty
200 if not opts['layout']:
201 s = 'null' # could be any other word, but this one makes sense
202 else:
203 s, _ = _format_layoutlist(opts['layout'])
204 script.append("ttk::style layout %s {\n%s\n}" % (name, s))
205
206 if opts.get('element create'): # format 'element create'
207 eopts = opts['element create']
208 etype = eopts[0]
209
210 # find where args end, and where kwargs start
211 argc = 1 # etype was the first one
212 while argc < len(eopts) and not hasattr(eopts[argc], 'items'):
213 argc += 1
214
215 elemargs = eopts[1:argc]
216 elemkw = eopts[argc] if argc < len(eopts) and eopts[argc] else {}
217 spec, opts = _format_elemcreate(etype, True, *elemargs, **elemkw)
218
219 script.append("ttk::style element create %s %s %s %s" % (
220 name, etype, spec, opts))
221
222 return '\n'.join(script)
223
224def _list_from_statespec(stuple):
225 """Construct a list from the given statespec tuple according to the

Callers 2

theme_createMethod · 0.85
theme_settingsMethod · 0.85

Calls 8

_format_optdictFunction · 0.85
_format_mapdictFunction · 0.85
_format_layoutlistFunction · 0.85
_format_elemcreateFunction · 0.85
itemsMethod · 0.45
getMethod · 0.45
joinMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected