Script To Swap Log Frame Between Secondary And Primary Splitter

39 views
Skip to first unread message

Thomas Passin

unread,
Jun 12, 2024, 1:21:20 PMJun 12
to leo-editor
When Leo comes to life, the Log frame normally shares the panel that has the tree.  I often like to have the Log frame next to the body editor instead.  This lets me see more of the tree at once and also gives the Log panel more vertical height.  This is often important for me.

The attached screen shot image shows both arrangements, with the standard on on the top.

In previous version of Leo, if you wanted to make a change like this you could try to fool around with the splitter context menu and if you got lucky enough or clever enough you could succeed.

With the new splitter code now in Leo it's much easier to write a little script to do the job.  Here's my script to toggle between the two arrangements.  I have it as the body of an @command node in myLeoSettings.leo, and I also have a custom menu item that runs it.

"""Move Nav frame between main and secondary splitters."""

gui = g.app.gui

ms = gui.find_widget_by_name(c, 'main_splitter')
ss = gui.find_widget_by_name(c, 'secondary_splitter')
lf = gui.find_widget_by_name(c, 'logFrame')

nav_in_secondary = ss.findChild(type(lf), "logFrame")
target = ms if nav_in_secondary else ss
target.addWidget(lf)

# Equalize sizes - "100000" must be larger than any of the widgets...
# and well less than MAX_INT
target.setSizes([100_000] * len(target.sizes()))


swap_nav_frame.png

Edward K. Ream

unread,
Jun 13, 2024, 1:44:15 PMJun 13
to leo-e...@googlegroups.com
On Wed, Jun 12, 2024 at 12:21 PM Thomas Passin <tbp1...@gmail.com> wrote:
When Leo comes to life, the Log frame normally shares the panel that has the tree.  I often like to have the Log frame next to the body editor instead.  This lets me see more of the tree at once and also gives the Log panel more vertical height.  This is often important for me.

Thanks, Thomas. Scripts like this were a motivation for Leo 6.8.0. And such scripts were why I was willing to have 6.8.0 be a breaking change from Leo's previous codebase.

Edward
Reply all
Reply to author
Forward
0 new messages