MCPcopy Index your code
hub / github.com/RustPython/RustPython / _format_elemcreate

Function _format_elemcreate

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

Callers 2

_script_from_settingsFunction · 0.85
element_createMethod · 0.85

Calls 6

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

Tested by

no test coverage detected