On Fri, Jul 19, 2024 at 5:27 AM Edward K. Ream <[email protected]> wrote:
> Next, I'd like to replace the vx switch. Leo's plugins manager can tell us whether VR or VR3 is running. Here is the dynamic version: Top level: """Change layout to Jacob Peck's layout # 3.""" # ref: https://gist.github.com/gatesphere/82c9f67ca7b65d09e85208e0b2f7eca1#file-render-focused g.cls() from leo.core.leoQt import Orientation @others # Define switch_layout. pc = g.app.pluginsController if pc.isLoaded('leo.plugins.viewrendered3'): cmd = 'vr3-show' import leo.plugins.viewrendered3 as vx switch_layout(cmd, vx) elif pc.isLoaded('leo.plugins.viewrendered'): cmd = 'vr-toggle' import leo.plugins.viewrendered as vx switch_layout(cmd, vx) else: print('No VR plugin enabled') The only child node is the following. It's Thomas's code wrapped in a function: def switch_layout(cmd: str, vx: Any) -> None: 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') edf = gui.find_widget_by_name(c, 'bodyFrame') init_orientation = ms.orientation() if init_orientation != Orientation.Horizontal: ms.setOrientation(Orientation.Horizontal) ss.setOrientation(Orientation.Vertical) ms.addWidget(lf) # Temporarily to get body to be second ss.addWidget(edf) ss.addWidget(lf) h = c.hash() vrx = vx.controllers.get(h) if not vrx: vx.controllers[h] = vrx = vx.ViewRenderedController3(c) ms.addWidget(vrx) if vrx.isHidden(): c.doCommandByName(cmd) ss.setSizes([100_000] * len(ss.sizes())) ms.setSizes([100_000] * len(ms.sizes())) Edward And here is the copy of the entire tree: <?xml version="1.0" encoding="utf-8"?> <!-- Created by Leo: https://leo-editor.github.io/leo-editor/leo_toc.html --> <leo_file xmlns:leo=" https://leo-editor.github.io/leo-editor/namespaces/leo-python-editor/1.1" > <leo_header file_format="2"/> <vnodes> <v t="ekr.20240719052742.1"><vh>dynamic layout3</vh> <v t="ekr.20240719054147.1"><vh>switch_layout</vh></v> </v> </vnodes> <tnodes> <t tx="ekr.20240719052742.1">"""Change layout to Jacob Peck's layout # 3.""" # ref: https://gist.github.com/gatesphere/82c9f67ca7b65d09e85208e0b2f7eca1#file-render-focused g.cls() from leo.core.leoQt import Orientation @others # Define switch_layout. pc = g.app.pluginsController if pc.isLoaded('leo.plugins.viewrendered3'): cmd = 'vr3-show' import leo.plugins.viewrendered3 as vx switch_layout(cmd, vx) elif pc.isLoaded('leo.plugins.viewrendered'): cmd = 'vr-toggle' import leo.plugins.viewrendered as vx switch_layout(cmd, vx) else: print('No VR plugin enabled') </t> <t tx="ekr.20240719054147.1">def switch_layout(cmd: str, vx: Any) -> None: 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') edf = gui.find_widget_by_name(c, 'bodyFrame') init_orientation = ms.orientation() if init_orientation != Orientation.Horizontal: ms.setOrientation(Orientation.Horizontal) ss.setOrientation(Orientation.Vertical) ms.addWidget(lf) # Temporarily to get body to be second ss.addWidget(edf) ss.addWidget(lf) h = c.hash() vrx = vx.controllers.get(h) if not vrx: vx.controllers[h] = vrx = vx.ViewRenderedController3(c) ms.addWidget(vrx) if vrx.isHidden(): c.doCommandByName(cmd) ss.setSizes([100_000] * len(ss.sizes())) ms.setSizes([100_000] * len(ms.sizes())) </t> </tnodes> </leo_file> EKR -- 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/CAMF8tS2KPD4mT1TSPxa-BUxw7rXq_ZcCwkHEH57PkvSJaz5ZDw%40mail.gmail.com.
