| On Thu, 2 May 2013 09:56:34 -0700
| Matt Wilkie <[email protected]> wrote:

| > I did eventually find the function and the docstrings, but """Inserts a 
| > new vnode as the last child of self. Returns the newly created 
| > position."""  doesn't help me much. My newbie python-fu is not at that 
| > level. :) It's okay, I'll get there sooner or later.

It's more Leo foo than Python, seems you're getting into the kind of
coding that needs the notes here:
http://leoeditor.com/scripting.html#c-g-and-p

but that section doesn't cover building trees from a script.  Usually
.insertAsLastChild() / .insertAsNthChild() is all you need.

e.g.

.. code:: python

  top = c.p.insertAfter()
  top.h = "Building a tree demo"
  top.expand()  # purely visual, not essential
  for sub in range(3):
      subnode = top.insertAsNthChild(0)  # first node
      subnode.h = "Backwards %s"%sub
      
      for subsub in range(3):
          subsubnode = subnode.insertAsLastChild()
          subsubnode.h = "Forwards %s-%s"%(sub, subsub)
  c.selectPosition(top)
  c.redraw()

Cheers -Terry

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to