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