Here's code that can be placed in a @button to save the current tabs.

    tablist = g.findNodeAnywhere(c, '@script load tabs')
    if not tablist:
        from leo.core.leoNodes import vnode
        v = vnode(c)
        v.h = '@script load tabs'
        v._linkAsNthChild(c.hiddenRootNode,
             len(c.hiddenRootNode.children))
    tablist = g.findNodeAnywhere(c, '@script load tabs')
    assert tablist
    import time
    b = ["# Generated %s\n"%time.strftime('%c')]
    for oc in g.app.commanders():
        b.append("g.openWithFileName('%s', c)" % oc.fileName())
    b.append("c.frame.bringToFront()")
    tablist.b = '\n'.join(b)

The button creates a @script node which will load the current tabs on
future openings of this file.

If I was Kent, I might put this in an @rclick node to it's a submenu
item of some general button collecting scripts like this.  If I was
anyone else, I'd have forgotten about the @rclick option and have to
take up valuable button bar space for it ;-)

If the node "@script load tabs" doesn't exist it's created at the
bottom of the file, but it can be moved anywhere.

For the first version I used g.handleUrlInUrlNode
instead of g.openWithFileName.  That just opened 3 instances of Google
Earth, so I prefer this version :-)

Edward - if the node "@script load tabs" doesn't exist in the outline,
I want to create it, at the *bottom*, and I'm sure there's a cleaner
way than I'm using here, but my attempts to iterate to the end of
c.rootPosition()'s siblings failed, probably just oversight on my part.

Cheers -Terry

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

Reply via email to