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

Function _mapdict_values

Lib/tkinter/ttk.py:56–75  ·  view source on GitHub ↗
(items)

Source from the content-addressed store, hash-verified

54 return _flatten(opts)
55
56def _mapdict_values(items):
57 # each value in mapdict is expected to be a sequence, where each item
58 # is another sequence containing a state (or several) and a value
59 # E.g. (script=False):
60 # [('active', 'selected', 'grey'), ('focus', [1, 2, 3, 4])]
61 # returns:
62 # ['active selected', 'grey', 'focus', [1, 2, 3, 4]]
63 opt_val = []
64 for *state, val in items:
65 if len(state) == 1:
66 # if it is empty (something that evaluates to False), then
67 # format it to Tcl code to denote the "normal" state
68 state = state[0] or ''
69 else:
70 # group multiple states
71 state = ' '.join(state) # raise TypeError if not str
72 opt_val.append(state)
73 if val is not None:
74 opt_val.append(val)
75 return opt_val
76
77def _format_mapdict(mapdict, script=False):
78 """Formats mapdict to pass it to tk.call.

Callers 2

_format_mapdictFunction · 0.85
_format_elemcreateFunction · 0.85

Calls 2

joinMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…