This script will safely undo all the layout changes we have been discussing
recently. It will work for most layouts that include zero, one, or both of
VR and VR3. It does not solve the general problem. One of many reasons for
that is that any Qt GUI widgets that may have been added by a user script
or plugin won't have a standard way to tear them down and unhook them from
Leo's event system. For any special case a savvy user may be able to
figure out how to do it but that won't work in general. These widgets also
won't have a general way to discover the object names that are needed.
The script returns to the original Leo default layout with the Tree and Log
frame on the left and the Body Editor on the right. It works with Leo
6.8.1 and the devel branch but I don't know if it will work for earlier Leo
versions.
Note that the way I import the VR module is a bit indirect. I could just
have used a regular import but this way is a template for a more general
future script where the object types may not be known ahead of time.
import importlib
from leo.core.leoQt import Orientation
gui = g.app.gui
MAIN_SPLITTER_ORIENTATION = Orientation.Horizontal
SECONDARY_SPLITTER_ORIENTATION = Orientation.Vertical
ms = gui.find_widget_by_name(c, 'main_splitter')
ss = gui.find_widget_by_name(c, 'secondary_splitter')
edf = gui.find_widget_by_name(c, 'bodyFrame')
lf = gui.find_widget_by_name(c, 'logFrame')
vr3 = gui.find_widget_by_name(c, 'viewrendered3_pane')
vr = gui.find_widget_by_name(c, 'viewrendered_pane')
edf_parent = edf.parent()
lf_parent = lf.parent()
delete_laters = set({})
if vr3:
c.doCommandByName('vr3-hide')
if vr:
v = importlib.import_module(vr.__module__)
vr.hide()
vr.closeEvent({})
vr.deleteLater()
h = c.hash()
del v.controllers[h]
ms.setOrientation(MAIN_SPLITTER_ORIENTATION)
ss.setOrientation(SECONDARY_SPLITTER_ORIENTATION)
if edf_parent != ms:
ms.insertWidget(2, edf)
edf.show()
if edf_parent != ss:
delete_laters.add(edf_parent)
if lf_parent != ss:
ss.insertWidget(2, lf)
lf.show()
if lf_parent != ms:
delete_laters.add(lf.parent)
for w in delete_laters:
w.deleteLater()
ms.setSizes([100_000] * len(ms.sizes()))
ss.setSizes([100_000] * len(ss.sizes()))
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/leo-editor/a92bba1b-3469-469b-9b62-0ca51279826fn%40googlegroups.com.