Mind Maps For Leo Now Available

164 views
Skip to first unread message

tbp1...@gmail.com

unread,
Aug 3, 2021, 9:45:39 PM8/3/21
to leo-editor
The Mind mapping commands are now available in scripts.leo, in this afternoon's commit of Leo's devel branch on GitHub.  The three scripts are in the new Mind Maps node, plus a README that tells how to use them.

A node that contains an indented list can be turned into a mind map.  The subtree headed by a selected node can be displayed as a depth-2 mind map.

The mind maps are in the form of SVG diagrams, and can be displayed by the Viewrendered3 or Freewin plugins, or by the system web browser.

Give it a try.

lewis

unread,
Aug 6, 2021, 5:48:42 AM8/6/21
to leo-editor
Tried out the Mindmap scripts and they are excellent! Thanks for all the work.

I have not used @commands before so it took me a while to realise the 3 scripts had to be children of the @commands node. It may help users if this is made clear in README>The Commands.

Running the mmap-tree command worked and created the @clean mmap.html node. I'm not sure this is actually a problem with the Mindmap script but I get this error in the log pane:

Leo Log Window
Leo 6.4-devel2, devel branch, build 27d3615ab2
2021-08-03 16:08:35 -0500
Python 3.9.6, PyQt version 5.15.2
Windows 10 AMD64 (build 10.0.19042) SP0

read outline in 3.24 seconds
VR3 stylesheet: N:/git/leo-editor/leo/plugins/viewrendered3/vr3_rst.css
Traceback (most recent call last):

  File "N:\git\leo-editor\leo\core\leoCommands.py", line 2203, in doCommand
return_value = command_func(event)

  File "N:\git\leo-editor\leo\plugins\viewrendered3.py", line 1242, in update_rendering_pane
vr3.update(tag='view', keywords={'c': c, 'force': True})

  File "N:\git\leo-editor\leo\plugins\viewrendered3.py", line 1908, in update
f(_tree, keywords)

  File "N:\git\leo-editor\leo\plugins\viewrendered3.py", line 2753, in update_rst
self.set_html(h, w)

  File "N:\git\leo-editor\leo\plugins\viewrendered3.py", line 3649, in set_html
w.setHtml(s, url_base)

TypeError: setHtml(self, str): too many arguments

Regards
Lewis

tbp1...@gmail.com

unread,
Aug 6, 2021, 8:31:46 AM8/6/21
to leo-editor
Thanks for the feedback.

On Friday, August 6, 2021 at 5:48:42 AM UTC-4 lewis wrote:
Tried out the Mindmap scripts and they are excellent! Thanks for all the work.

: )
 
I have not used @commands before so it took me a while to realise the 3 scripts had to be children of the @commands node. It may help users if this is made clear in README>The Commands.

That's odd, because I have quite a few @command nodes that are not under an @commands parent.  In fact, I even have an @string setting mixed in with the mind map commands under @commands, and that works.  The commands I have that are not under an @commands node are in a separate outline, not myLeoSettings.leo.  I wonder if that makes a difference.  Maybe someone who knows more can tell us the facts here. 
 
Running the mmap-tree command worked and created the @clean mmap.html node. I'm not sure this is actually a problem with the Mindmap script but I get this error in the log pane:

That seems to be an error with Viewrendered3.  I haven't seen it before (I'm its developer).  My version of Leo is the same as yours:

Leo 6.4-devel2, devel branch, build 27d3615ab2
2021-08-03 16:08:35 -0500
Python 3.9.5, PyQt version 5.15.2
Windows 10 AMD64 (build 10.0.19043) 

It seems very unlikely that Python 3.9.5 vs 3.9.6 or the minor Windows version could be a factor.  Have you gotten this error any other time with VR3?  If you run the mind map command again, do you get it again?  Do you get it if you make a mind map on a different node?  I just made several mind maps using VR3 for the output and did not get any errors.

Would you do me a favor?  Enable the Freewin plugin, and add a new setting with headline @string mmap_render_dev = freewin.  This could be in an outline or in myLeoSettings.leo.  Reload settings.  Then make a mind map on the same node as before.  The output will open in Freewin instead of VR3.  Post here whether you get any errors doing it that way.

If you wanted to make one more test for me, you could change the setting to browser and again see if you get an error making the mind map.

lewis

unread,
Aug 6, 2021, 8:41:43 PM8/6/21
to leo-editor
Hi Thomas,
I have the @command scripts in myLeoSettings.leo not in a separate outline.
If I move the @command scripts up to the same level as @commands, running mmap-tree causes Leo to crash with no console messages.
The crash also occurred with headline @string mmap_render_dev = freewin and = browser. I confirmed this several times.

This matches leoSettings.leo>\@commands node which states:
"Denotes the tree containing active @command nodes. @command nodes outside this tree are ignored."

I will retest with the @command scripts in the separate outline and let you know.

tbp1...@gmail.com

unread,
Aug 6, 2021, 9:18:25 PM8/6/21
to leo-editor
Interesting and I don't know what to make of it.  The best thing to do would be just to put them all under an @commands node.  Anything about just how the commands are registered with Leo and exactly how Leo invokes them is, of course, way beyond the scripts themselves.  Mostly I'm interested in what's going on with VR3 and those error messages.

tbp1...@gmail.com

unread,
Aug 6, 2021, 9:23:19 PM8/6/21
to leo-editor
I would say that after you move the scripts back under an @commands node that it would be best to restart Leo to be on the safe side.  I have noticed that when I add some @command and reload settings but don't restart Leo, the new command doesn't get registered.  Once it's there, one can usually modify the script and the command will still run it. (The mmap-xxx commands are a little different in that the mmap-monkeypatch script (not the command) needs to be run again.  But that's not something that would ever need to be done in normal use).

lewis

unread,
Aug 8, 2021, 2:59:45 AM8/8/21
to leo-editor
Mostly I'm interested in what's going on with VR3 and those error messages.

I disabled myLeoSettings and used the default leoSettings.leo to rule out any custom settings. The @command scripts are in the local outline and at the same level as @commands, @string mmap_render_dev = vr3
I ran mmap-tree and get:

Leo Log Window
Leo 6.4-devel2, devel branch, build 27d3615ab2
2021-08-03 16:08:35 -0500
Python 3.9.6, PyQt version 5.15.2
Windows 10 AMD64 (build 10.0.19042) SP0
read outline in 0.03 seconds
unexpected exception in g.getScript

Traceback (most recent call last):

  File "N:\git\leo-editor\leo\core\leoGlobals.py", line 7429, in getScript
    s = g.extractExecutableString(c, p, s)

  File "N:\git\leo-editor\leo\core\leoGlobals.py", line 7477, in extractExecutableString
    language = g.scanForAtLanguage(c, p)

  File "N:\git\leo-editor\leo\core\leoGlobals.py", line 3522, in scanForAtLanguage
    for p in p.self_and_parents(copy=False):

  File "N:\git\leo-editor\leo\core\leoNodes.py", line 527, in self_and_parents
    p = p.copy()

  File "N:\git\leo-editor\leo\core\leoNodes.py", line 1414, in copy
    return Position(self.v, self._childIndex, self.stack)

RecursionError: maximum recursion depth exceeded
[end]

And with the @command scripts as children of @commands node, here are error messages :
VR3 stylesheet: N:/git/leo-editor/leo/plugins/viewrendered3/vr3_rst.css
Traceback (most recent call last):

  File "N:\git\leo-editor\leo\core\leoCommands.py", line 2203, in doCommand
    return_value = command_func(event)

  File "N:\git\leo-editor\leo\plugins\viewrendered3.py", line 1242, in update_rendering_pane
    vr3.update(tag='view', keywords={'c': c, 'force': True})

  File "N:\git\leo-editor\leo\plugins\viewrendered3.py", line 1908, in update
    f(_tree, keywords)

  File "N:\git\leo-editor\leo\plugins\viewrendered3.py", line 2753, in update_rst
    self.set_html(h, w)

  File "N:\git\leo-editor\leo\plugins\viewrendered3.py", line 3649, in set_html
    w.setHtml(s, url_base)

TypeError: setHtml(self, str): too many arguments
[end]

Hope it helps
Lewis

tbp1...@gmail.com

unread,
Aug 8, 2021, 11:47:42 AM8/8/21
to leo-editor
I just had an idea about this.  The error message says that the calling signature is wrong.  That could happen if you don't have PyQtWebEngine installed for some reason.  In that case, VR3 falls back to a different widget, and that widget uses a different signature, the one that your error message shows.  Although it normally gets installed when Leo is installed, I have known cases where the WebEngine was missing.

It will take a bit of finagling for me to test this, which I will do later.  In the meantime, would you check to see if PyQtWebEngine is installed?  Here are two ways:

1. In a console, run this command (you system may use py instead of python3, but use whatever name you normally use):

python3 -m pip list

There should be a line like

PyQtWebEngine                 5.15.4

2. Run a Python session, and run these two lines:

from leo.core.leoQt import QtWebKitWidgets
print(type(QtWebKitWidgets))

If the response is <class 'NoneType'>, then you do not have PyQtWebEngine installed.  You would install it from a console with this command:

py -m pip install --upgrade PyQtWebEngine

In fact, it might be worth doing this even if you do have it installed, just in case an update might fix something that isn't right.

tbp1...@gmail.com

unread,
Aug 8, 2021, 12:14:15 PM8/8/21
to leo-editor
I just confirmed that you will get the error message you posted if PyQtWebEngine is missing.  I will see if I can do something about that (it may be that the fallback widget can't display the diagram, but at least it should not give an error).

tbp1...@gmail.com

unread,
Aug 8, 2021, 2:12:12 PM8/8/21
to leo-editor
I have fixed this condition - if PyQt has been installed but for some reason not PyQtWebEngine.  The fallback substitute rendering widget (a QTextBrowser) can't display the diagrams, but 1) it does not cause an error, and 2) you can export the diagram to the system web browser, which can display it.  I've put in a PR, and will post here when it is available in the devel branch.

I also discovered that the mind mapping commands don't work with PyQt6 - certain methods and so forth have had their names changed since PyQt5.  I'll get that taken care of (and a couple of other improvements) and issue a PR for the changes 

tbp1...@gmail.com

unread,
Aug 8, 2021, 2:55:37 PM8/8/21
to leo-editor
Fixed.  Also if the label for the central image contains a Leo directive (e.g., "@clean"), only the basename is shown, not the whole path truncated as before.  A PR has been issued for these changes.  I'll post here when it has been accepted.

lewis

unread,
Aug 8, 2021, 10:40:21 PM8/8/21
to leo-editor
Installing PyQtWebEngine fixed the problem. Thanks for the tip.
The rendering works well for both browser and vr3.

However with setting @string mmap_render_dev = freewin
the freewin window launches but pressing the [Rendered<-->Plain] toggle renders a list not a tree. This behavior occurs on 2 machines.

Regards
Lewis


tbp1...@gmail.com

unread,
Aug 8, 2021, 11:41:28 PM8/8/21
to leo-editor
I'm not sure what you mean by rendering a list.  The mmap output would be svg, not a text list.  When FW opens, it will show the svg source.  When the render toggle is pressed, it should show the diagram, or possibly something indecipherable if the fallback widget is being used, but I don't know how it could show a "list".

Maybe you mean something different than I am thinking of.  Would you please post a screen shot of the FW rendered output?

There is a setting to force FW to use the fallback rendering widget.  The advantage is that the F9 and F7 keys work the same as they do when the Zettlekasten commands are installed.  The disadvantage is that that widget can't render svg diagrams or other complex html.  The default is to use the normal widget, which can render svg diagrams.  The setting is @string fw-render-pane. You can only get the fallback widget if the value of the setting is exactly nav-view.

FW would also have been affected by not having the PyQtWebEngine, but I assume you tested FW after installing it.  One thing to remember is that after making a change to a mmap setting, then in the outline you want to work in, all settings must be reloaded and the mmap-monkeypatch command must be run - or Leo must be restarted.  I may be able to simplify that in the future, we'll see...

Oh yes, and thank you for doing this testing and for your patience!

lewis

unread,
Aug 9, 2021, 1:22:26 AM8/9/21
to leo-editor
I've read your first post Progress Report - Mind Maps for Leo and am trying to understand the difference between mmap-tree and mmap-list commands. It says:
The mind mapping system now works via a set of minibuffer commands.  You can put an indented list into a node and display it as a mind map.  Or you can display an entire subtree as a mind map.
....
One of these scripts takes an indented list in the selected node and feeds it to the monkey-patched script.  The other one converts a tree starting at the selected node to an indented list and then feeds it to the monkey-patched script.

I see how mmap-tree command works on an entitre subtree and creates the svg tree.
I'm not sure how mmap-list command works taking an indented list from a node. Can you give an example of an 'indented list' and an example of the output?

tbp1...@gmail.com

unread,
Aug 9, 2021, 9:07:28 AM8/9/21
to leo-editor
Here is a screen shot of an indented list in a node, with the rendering being done by Freewin.

Back in the days when the Mind Manager program was simpler and less expensive, it could output a mind map as an indented list, and turn an indented list into a bare bones mind map.  Maybe its successor still can, but these days it's too complex and expensive for me to get just to fool around with.

mmap-list-example.png

tbp1...@gmail.com

unread,
Aug 9, 2021, 9:14:03 AM8/9/21
to leo-editor
I've made the changes I mentioned - the commands now work under PyQt6 as well as PyQt5, and the central image displays just the file name if it's something with a directive and a path, like @file ../plugins/plugin.py.

I also adjusted the Viewrendered3 plugin so that it works without an error if the PyQtWebEngine is not installed.  In that case it won't be able to actually render the diagram, but you can still export it to a browser.

Both sets of changes are in the most recent changeset in the devel branch.

Edward K. Ream

unread,
Aug 9, 2021, 10:41:25 AM8/9/21
to leo-editor
On Mon, Aug 9, 2021 at 8:07 AM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
Here is a screen shot of an indented list in a node, with the rendering being done by Freewin.

Very cool!

Edward

tbp1...@gmail.com

unread,
Aug 9, 2021, 1:45:40 PM8/9/21
to leo-editor
The mmap-tree works by creating an indented list from the outline nodes, then feeding that into an indented list parser whose output is consumed by the layout code.  So I get the mmap-list command basically for free.  I was very happy when I saw it could be done that way - two for one!

lewis

unread,
Aug 11, 2021, 4:08:14 AM8/11/21
to leo-editor
Using both commands mmap-list and mmap-tree renders correctly with either setting
@string mmap_render_dev = browser or @string mmap_render_dev = vr3

However output with setting @string mmap_render_dev = freewin does not render as a tree. I have attached a screenshot of the rendering.

Regards
Lewis
mmap-list_freewin.png

tbp1...@gmail.com

unread,
Aug 11, 2021, 8:42:34 AM8/11/21
to leo-editor
This behavior means that Freewin is using its alternate rendering widget for some reason.  This widget can't actually render the diagram, and when it tries it presents the appearance of your screenshot.  Now that you have QWebEngine installed, FW should be using it instead of the alternate one.  The only way the alternate widget would be in use is if you used the @string fw-render-pane = nav-view setting.  If you do have that setting in play, that would be the reason.  If not, there is a real mystery because FW uses the exact same import commands as VR3, and would give you a message on startup if it couldn't import QWebEngine.

Very few people should be using that setting, because it is useful only in a very specific context: the user has installed the Zettelkasten commands and wants to use F7 and F9 in the rendered view and have them work the same as they do in the Leo body editor and the FW editing view.

So if that applies to you, you will have to choose between having those keyboard shortcuts working in rendering view or being able to render a mind map in FW.  If it doesn't, and you are using that setting, just remove it and restart Leo.

If you are not using that setting at all, and you are using a recent devel branch - and VR3 is able to render the mind maps correctly - then I'm extremely puzzled.  The only way I can see to make progress, would be for me to send you some diagnostic lines of code to insert into the FW code, if you'd be willing to do that ( or I could perhaps add a debug mode to FW) and hope that it would disclose the reason for all this.
Reply all
Reply to author
Forward
0 new messages