Script To Move Nav Frame Between Secondary And Primary Splitters

16 views
Skip to first unread message

Thomas Passin

unread,
May 26, 2024, 6:54:49 PMMay 26
to leo-editor
In practice, this means changing which panel the Nav frame shares:
1. Next (usually to the right) to the body editor; or
2. Next (usually below) the tree.

With the old nested splitter layout Leo had for so long, it was possible to get this arrangement using the context menu of the splitter bar, but it wasn't very obvious how.

With the new layout code and the retirement of the nested splitter and the splitter bar menu, can this be done? Yes, here is a script.  It could be used as a model for moving other frames.  Each time it is run, the Nav frame trades places.

"""Move Nav frame between main and secondary splitters."""
from leo.core.leoQt import QtWidgets
QFrame = QtWidgets.QFrame

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(QFrame, "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()))

Thomas Passin

unread,
May 26, 2024, 11:17:19 PMMay 26
to leo-editor
It can be done without the import, making the script two lines shorter:

"""Move Nav frame between main and secdary 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()))
Reply all
Reply to author
Forward
0 new messages