MCPcopy Index your code
hub / github.com/python/cpython / _format_elemcreate

Function _format_elemcreate

Lib/tkinter/ttk.py:94–135  ·  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

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

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…