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

Function _format_elemcreate

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

Formats args and kw according to the given element factory etype.

(etype, script=False, *args, **kw)

Source from the content-addressed store, hash-verified

94 return _flatten(opts)
95
96def _format_elemcreate(etype, script=False, *args, **kw):
97 """Formats args and kw according to the given element factory etype."""
98 spec = None
99 opts = ()
100 if etype in ("image", "vsapi"):
101 if etype == "image": # define an element based on an image
102 # first arg should be the default image name
103 iname = args[0]
104 # next args, if any, are statespec/value pairs which is almost
105 # a mapdict, but we just need the value
106 imagespec = _join(_mapdict_values(args[1:]))
107 spec = "%s %s" % (iname, imagespec)
108
109 else:
110 # define an element whose visual appearance is drawn using the
111 # Microsoft Visual Styles API which is responsible for the
112 # themed styles on Windows XP and Vista.
113 # Availability: Tk 8.6, Windows XP and Vista.
114 class_name, part_id = args[:2]
115 statemap = _join(_mapdict_values(args[2:]))
116 spec = "%s %s %s" % (class_name, part_id, statemap)
117
118 opts = _format_optdict(kw, script)
119
120 elif etype == "from": # clone an element
121 # it expects a themename and optionally an element to clone from,
122 # otherwise it will clone {} (empty element)
123 spec = args[0] # theme name
124 if len(args) > 1: # elementfrom specified
125 opts = (_format_optvalue(args[1], script),)
126
127 if script:
128 spec = '{%s}' % spec
129 opts = ' '.join(opts)
130
131 return spec, opts
132
133def _format_layoutlist(layout, indent=0, indent_size=2):
134 """Formats a layout list so we can pass the result to ttk::style

Callers 2

_script_from_settingsFunction · 0.85
element_createMethod · 0.85

Calls 5

_joinFunction · 0.90
_mapdict_valuesFunction · 0.85
_format_optdictFunction · 0.85
_format_optvalueFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected