def tree_to_treesegment(canvas, t, make_node=TextWidget, make_leaf=TextWidget, **attribs):
 tree_attribs = {}
 node_attribs = {}
 leaf_attribs = {}
 loc_attribs = {}
 for (key, value) in list(attribs.items()):
  if (key[:5] == 'tree_'):
   tree_attribs[key[5:]] = value
  elif (key[:5] == 'node_'):
   node_attribs[key[5:]] = value
  elif (key[:5] == 'leaf_'):
   leaf_attribs[key[5:]] = value
  elif (key[:4] == 'loc_'):
   loc_attribs[key[4:]] = value
  else:
   raise ValueError(('Bad attribute: %s' % key))
 return _tree_to_treeseg(canvas, t, make_node, make_leaf, tree_attribs, node_attribs, leaf_attribs, loc_attribs)

def tree_to_treesegment ( canvas , t , make_node = TextWidget , make_leaf = TextWidget , ** attribs ) : tree_attribs = { } node_attribs = { } leaf_attribs = { } loc_attribs = { } for ( key , value ) in list ( attribs . items ( ) ) : if ( key [ : 5 ] == 'tree_' ) : tree_attribs [ key [ 5 : ] ] = value elif ( key [ : 5 ] == 'node_' ) : node_attribs [ key [ 5 : ] ] = value elif ( key [ : 5 ] == 'leaf_' ) : leaf_attribs [ key [ 5 : ] ] = value elif ( key [ : 4 ] == 'loc_' ) : loc_attribs [ key [ 4 : ] ] = value else : raise ValueError ( ( 'Bad attribute: %s' % key ) ) return _tree_to_treeseg ( canvas , t , make_node , make_leaf , tree_attribs , node_attribs , leaf_attribs , loc_attribs )
convert a tree into a treesegmentwidget .