On 1/3/2014 4:07 PM, Jack Kuan wrote:
Hi,
I have written a script and made a button for it. I can run it(click
the button) on one selected node, but how do I make it run ALL
selected nodes?
This is tricky, and Edward has been pushing towards disallowing Leo from
having multiple selected nodes (a huge mistake IMO).
Instead of using p in your script, use c.getSelectedPositions() to get a
list, and then iterate over that list:
alist = c.getSelectedPositions()
for pos in alist:
g.es(pos.h)
Also, is there a find command that will let me execute my script on
all found nodes?
Well, this is a case-by-case thing, relatively difficult to generalize...
You can do this:
foundNodes = []
for pos in c.all_positions():
if 'someString' in pos.h: foundNodes.append(pos)
for pos in foundNodes:
g.es(pos.h)
That script searches the entire outline for nodes that have 'someString'
in their headlines, and then iterates over them.
In general, when working with multiple nodes in Leo, you're going to
want to do a for-each loop over a list or generator.
Hope this helps!
-->Jake
Thanks
Jack
--
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.
For more options, visit https://groups.google.com/groups/opt_out.
--
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.
For more options, visit https://groups.google.com/groups/opt_out.