Construct a list from the given statespec tuple according to the accepted statespec accepted by _format_mapdict.
(stuple)
| 227 | return '\n'.join(script) |
| 228 | |
| 229 | def _list_from_statespec(stuple): |
| 230 | """Construct a list from the given statespec tuple according to the |
| 231 | accepted statespec accepted by _format_mapdict.""" |
| 232 | if isinstance(stuple, str): |
| 233 | return stuple |
| 234 | result = [] |
| 235 | it = iter(stuple) |
| 236 | for state, val in zip(it, it): |
| 237 | if hasattr(state, 'typename'): # this is a Tcl object |
| 238 | state = str(state).split() |
| 239 | elif isinstance(state, str): |
| 240 | state = state.split() |
| 241 | elif not isinstance(state, (tuple, list)): |
| 242 | state = (state,) |
| 243 | if hasattr(val, 'typename'): |
| 244 | val = str(val) |
| 245 | result.append((*state, val)) |
| 246 | |
| 247 | return result |
| 248 | |
| 249 | def _list_from_layouttuple(tk, ltuple): |
| 250 | """Construct a list from the tuple returned by ttk::layout, this is |
no test coverage detected
searching dependent graphs…