(items)
| 54 | return _flatten(opts) |
| 55 | |
| 56 | def _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 | |
| 77 | def _format_mapdict(mapdict, script=False): |
| 78 | """Formats mapdict to pass it to tk.call. |
no test coverage detected
searching dependent graphs…