locate one node by it's path via leoBridge

32 views
Skip to first unread message

Austin(Xu) Wang

unread,
Aug 24, 2019, 1:46:07 AM8/24/19
to leo-editor
Dear Leo User,

I want to access the headline and body of a specific node inside that file using the leoBridge interface.
Is it possible to get the body and headline from the path of that node?

For example, for one node with headline "Display Message":
/Users/wangxu/Documents/Leo/austin.leo#IT-->Leo-->Writing Plugin-->Display Message

Is it doable to implement function:
- get_headline ("IT-->Leo-->Writing Plugin-->Display Message")
- get_body ("IT-->Leo-->Writing Plugin-->Display Message")

Please guide me on this..

BR,Austin

Austin(Xu) Wang

unread,
Aug 24, 2019, 3:07:44 AM8/24/19
to leo-editor

I realized  get_headline ("IT-->Leo-->Writing Plugin-->Display Message") is with no sense..

What I want is:

- get_child_headlines ("IT-->Leo-->Writing Plugin-->Display Message")      # return a list of headlines for each child node.
- get_body ("IT-->Leo-->Writing Plugin-->Display Message")                       # return the body text

vitalije

unread,
Aug 24, 2019, 5:00:21 AM8/24/19
to leo-editor
You can try the following:
def get_child_headlines(c, address):
   
return g.recursiveUNLSearch(address.split('-->'), c)

You can find nodes even faster if you know their gnx (you can obtain a gnx value by using p.gnx or v.gnx). 
def get_node(c, gnx):
   
return c.fileCommands.gnxDict.get(gnx)

def get_body_and_headline(c, gnx):
    v
= get_node(gnx)
   
return v.h, v.b

I assume that you have obtained the address of the node "IT-->Leo-->Writing Plugin-->Display Message" by copying it from the status line in Leo window. If you want to copy gnx of some node you can do this using the following script.
g.app.gui.replaceClipboardWith(p.gnx)

This script you can make a button of it and then when you want to copy gnx of some node, just select it and click the button.

HTH Vitalije

Austin(Xu) Wang

unread,
Aug 24, 2019, 7:37:44 AM8/24/19
to leo-editor
thanks vitalije for the instruction. much appreciated. 
Reply all
Reply to author
Forward
0 new messages