Basic concepts of using Leo to organise a python program

196 views
Skip to first unread message

lewis

unread,
Nov 21, 2017, 6:45:44 AM11/21/17
to leo-editor
I have been searching Leo documentation for a simple guide to using Leo and to write python files but it seems to have disappeared or my memory is awry.
"What’s the best way to learn to use Leo?" at section:  If you intend to use Leo for programming, read the programming tutorial. This link is broken.

Maybe this was the simple tutorial?
I recall it showed the basic concepts of using Leo to organise a python program.

Regards
Lewis

Edward K. Ream

unread,
Nov 21, 2017, 10:21:58 AM11/21/17
to leo-editor
On Tue, Nov 21, 2017 at 5:45 AM, lewis <lewi...@operamail.com> wrote:
I have been searching Leo documentation for a simple guide to using Leo and to write python files but it seems to have disappeared or my memory is awry.
"What’s the best way to learn to use Leo?" at section:  If you intend to use Leo for programming, read the programming tutorial. This link is broken.

​Thanks for this.  I'll fix it today.

Edward

Edward K. Ream

unread,
Nov 21, 2017, 3:26:37 PM11/21/17
to leo-editor
​Done at 444760f and uploaded to the web:

Edward

Christophe Vermeulen

unread,
Mar 18, 2022, 11:10:22 AM3/18/22
to leo-editor
Well the original programming tutorial link wasn't restored, it seems. Funny enough, the FAQ link works, but there is also no "outliner" entry (anymore) in glossary (though outline exists, but apparently without anchor.).

Would you (Edward or the community) be interested in a NOOB-directed contribution ? To be honest, I don't think TheBrain is what people that don't use clones should stick with. I tried (several years away) and God it was so weird. Yes you can link whatever with whatever, but what is the "value" you get back from this ? While I see leo as a tool that can deliver something usable, both in the form of a program (useful for some of my activities) or a document (useful for others). Now, maybe leo could also import TheBrain files ? ;-)

Edward K. Ream

unread,
Mar 18, 2022, 11:12:27 AM3/18/22
to leo-editor
Would you (Edward or the community) be interested in a NOOB-directed contribution ?

Sure.  That's how people stop being newbies :-)  PR's are always welcome.

Edward

tbp1...@gmail.com

unread,
Mar 18, 2022, 11:28:31 AM3/18/22
to leo-editor
I've tried TheBrain maybe three times over these many years.  It always seems so promising, and I always abandon it with frustration.

On Friday, March 18, 2022 at 11:10:22 AM UTC-4 cve...@gmail.com wrote:
... Now, maybe leo could also import TheBrain files ? ;-)

Now there is an interesting idea.  A Brain file is a .brz (not actually .zip, but same idea).  It has a lot of individual json files that obviously have to work together, along with some icon files. Much of the data  is metadata, which might or might not be of interest.  The big thing to settle would be how present it all, and one big question there is whether there can be cycles, and if so, how to handle them..

tbp1...@gmail.com

unread,
Mar 18, 2022, 2:07:27 PM3/18/22
to leo-editor
Having downloaded one of the example brains, and looked at a few of the online examples, I'm coming to think that a combination of the browser bookmark manager scripts I'm working on together, perhaps, with the zettelkasten-style organizing scripts I offered in a different thread, would provide similar capabilities.  Add some enhancements to the mind mapping script I provided a while ago, and we might be able to have a really good alternative.

tbp1...@gmail.com

unread,
Mar 18, 2022, 2:12:18 PM3/18/22
to leo-editor
Actually,  just the browser bookmark scripts and optionally the mind mapping visualization, would probably do it.

tbp1...@gmail.com

unread,
Mar 21, 2022, 1:01:46 AM3/21/22
to leo-editor
I fooled around with a sample Brain project on the Brain's web site.  I was able to import the "thoughts" and links.  The project file contains a number of .json files, although they are not actually valid json.  But it's possible to work with them anyway.  So yes, it's not hard to do an import.  The bigger question would be what kind of interface would work well with them and how it would fit into Leo's node system.  Contrary to what I speculated above, the thoughts and their links do not look much like bookmark collections.  Basically, each "thought" node has both incoming and outgoing links, potentially of any number.  It is possible that they would fit into the zettelkasten paradigm, which is basically one way to synthesize multiple incoming and outgoing links.  But whether that would be a good approach or not, the interface and display are what need to be invented.  There would be no point in trying to reproduce what The Brain already has!

Christophe Vermeulen

unread,
Mar 21, 2022, 4:31:38 AM3/21/22
to leo-editor
It doesn't surprise me. That's indeed the strength of the Brain (to me), it is basically a mindmap but with the *current thought* as the center, it's not hierarchical. In that sense it is different from an outlook.
OTOH, in zettelkasten I get the impression that the focus is on the taking of notes in an outline, and just adding #tags and links between the notes. I don't directly see there anything that leo couldn't do better. Can you clarify what you have in mind here ?

tbp1...@gmail.com

unread,
Mar 21, 2022, 10:27:10 AM3/21/22
to leo-editor
I've used and liked mind maps very a long time, and I'm very picky about their appearance.  I started with Tony Buzan's book, before there were programs to make mind maps.  Mind Maps were among other things an excellent memory aid for me.  I used to take meeting notes as mind maps in real time (by hand), and I found time after time that I could pick up one of them say five years later, and in five or ten minutes I could reconstruct the whole meeting.  I also taught several graduate level classes using mind maps as my lecture notes.  It worked wonderfully well.

I dislike almost all the mind mapping programs out there that I've tried, including the Brain, mostly because their appearance doesn't suit me, or the way you interact with them works poorly, etc., etc.  I used to use the old Mind Manager product (I'm talking 15+ years ago) and liked that pretty well.  But now the successor is way too complex and garbaged up, and pretty expensive to boot.  So I don't use it.

The one thing a mind map doesn't do is to show incoming edges - that is, "predecessor" nodes.  That's not a bad thing, but it prevents one from moving freely around a large knowledge base.  It's not the intended use of mind maps, so it's not  defect in the basic idea.  If you want to make effective use of a knowledge base it's a weakness, one that The Brain has tackled.  But because of the emphasis on "thoughts", the Brain is weak on the relationships, which is where the real meat of a knowledge base is or should be.  And I don't like the way their displays shift around.

The zettelkasten approach is as you say about notes, but that's a superficial view.  It's much more about the connections, and also, if we go along with the original, the "notes" are intended to be carefully thought out summaries of various thought fragments, not simply reminders dashed off in a hurry.

Leo's basic structure of a node for everything has proved to be quite wonderful.  It is limited a bit because the nodes are text only, but that's for the most part livable.  A node has a single incoming edge (not counting clones - clones introduce a sort of hybrid model, and I don't want to get into it here).  So if we want to have a node with multiple incoming edges, and outgoing edges that link to nodes that aren't "child" nodes, we need to carry more information, and we need a way to visualize and navigate the system.

There are many ways to carry more link information.  For the zettelkasten system I worked out some time ago (there are one or two threads on that from a year or more ago) I use gnx identifiers (Leo's internal node ids) with notation in each node's body to define a link.  For my browser bookmark manager - still in progress - I use Leo's UNL paths to construct internal links each time a display is built.  One could also use UAs (User Attributes) though I haven't felt the need to so far.

It's the visualization and navigation of any system that is based on graphs that's the hard part.  It's hard both from a design/UI point of view and from an implementation point of view.  The really nice part of basing these systems on Leo is how easy it is to reorganize, restructure, and edit the information.  I have found that to be a real strong point.  The disadvantage is that there is no intrinsic graphical subsystem/API for displaying the information (preferably with links).

I'm inclined to think that using Graphviz may be good for generating some of these displays.  Since Graphviz is a stand-alone console-based C program, it may turn out that a server is needed to interact with it effectively. Leo already has the skeleton of such a server, and the leointeg project (that lets you work on Leo outlines in Visual Studio Code) is a proof of principle.

Whew, that was longwinded!  If you want to pursue this subject further, we should probably start a new thread.  You can see that it's a topic I'm very interested in.

Christophe Vermeulen

unread,
Mar 21, 2022, 10:56:08 AM3/21/22
to leo-editor
Definitely, and I appreciate your (and Edward's) responsiveness and openness. I don't grasp everything in your message (yet), I only installed leo on one computer yesterday and was a bit surprised to see it (pip actually) download PyQt5 just after I had manually installed PyQt6, and ... not installing leo6.6 but an older version. I expected Qt would be used for some visualization, but I have no experience with it either. I'm still out on the priority to cover my "information bowls" in leo (between my Python logfile mill, long-term food reserve management, Belgium addresses with fibers, home climate control, etc.) Most imply some future Python code, but I actually hope that leo would help me see more clearly where I should put my efforts first, by evaluating the "RoI" of everything I put in. 

tbp1...@gmail.com

unread,
Mar 21, 2022, 11:28:29 AM3/21/22
to leo-editor
On Monday, March 21, 2022 at 10:56:08 AM UTC-4 cve...@gmail.com wrote:
Definitely, and I appreciate your (and Edward's) responsiveness and openness. I don't grasp everything in your message (yet), I only installed leo on one computer yesterday and was a bit surprised to see it (pip actually) download PyQt5 just after I had manually installed PyQt6, and ... not installing leo6.6 but an older version.

Version 6.6 hasn't been released yet, that's why you got 6.5 using pip.  Those of us using non-release versions of 6.6 are getting them from the Github repository.  They change pretty often, and could have bugs that will (we hope) be fixed).

As of 6.5, IIRC, Leo didn't officially support Qt6.  That's because Qt6 didn't include certain parts that Leo might use.  Also, there were some API changes with Qt6.  By Qt 6.23, and current development versions of Leo, both of these issues have been resolved and Leo can use either Qt5 or Qt6, whichever is available.  
 
I expected Qt would be used for some visualization, but I have no experience with it either.

Leo uses Qt for all the UI (User Interface) elements - the trees, text editor, menus, etc. Internally, Leo is written so that it can be adapted to other graphics rendering systems, but I doubt that Qt will be replaced anytime soon.  For display of graphical material, not one of Leo's strong points so far, there are several possibilities.  These include:

1. Reference the image in a Markdown or Restructured text node, then display it in the Viewrendered or Viewrendered3 plugin.
2. Compute the SVG that describes a graphic, and display that with the VR or VR3 plugins, or send it to your web browser.
3. Write a script that produces a graph description - for example, the Graphviz description language - and use a batch file to send it to graphviz and then display it in your web browser.  Your command could launch the batch file.  This is not hard to do, though it will take a little learning to get up to speed on how.

Here, by "script" I mean a small Python program that runs inside of Leo and (usually) uses Leo features.
 
I'm still out on the priority to cover my "information bowls" in leo (between my Python logfile mill, long-term food reserve management, Belgium addresses with fibers, home climate control, etc.) Most imply some future Python code, but I actually hope that leo would help me see more clearly where I should put my efforts first, by evaluating the "RoI" of everything I put in. 

Leo is *really good* for developing Python code.  It may take some time to fully appreciate just how good since there isn't any tutorial-type document that walks you through all of it.  (There are tutorials, though). And Leo's abilities can be extended by Python scripts (programs) that add new commands.  For example, I wrote a script that generates and displays a mind map of the selected Leo subtree. It gets launched like most other Leo commands.
Reply all
Reply to author
Forward
0 new messages