def _list_from_layouttuple(tk, ltuple):
 ltuple = tk.splitlist(ltuple)
 res = []
 indx = 0
 while (indx < len(ltuple)):
  name = ltuple[indx]
  opts = {}
  res.append((name, opts))
  indx += 1
  while (indx < len(ltuple)):
   (opt, val) = ltuple[indx:(indx + 2)]
   if (not opt.startswith('-')):
    break
   opt = opt[1:]
   indx += 2
   if (opt == 'children'):
    val = _list_from_layouttuple(tk, val)
   opts[opt] = val
 return res

def _list_from_layouttuple ( tk , ltuple ) : ltuple = tk . splitlist ( ltuple ) res = [ ] indx = 0 while ( indx < len ( ltuple ) ) : name = ltuple [ indx ] opts = { } res . append ( ( name , opts ) ) indx += 1 while ( indx < len ( ltuple ) ) : ( opt , val ) = ltuple [ indx : ( indx + 2 ) ] if ( not opt . startswith ( '-' ) ) : break opt = opt [ 1 : ] indx += 2 if ( opt == 'children' ) : val = _list_from_layouttuple ( tk , val ) opts [ opt ] = val return res
construct a list from the tuple returned by ttk::layout .