I have made several apps (really, "applets") to run in tabs in Leo's Log frame. I find this convenient because they don't need to take up a whole panel, as Viewrendered/Viewrendered3 do, and they don't even need to be plugins so they can be simpler. They are mostly intended to be used in a specific outline; their code can reside in the outline.
I wanted to share how I open these apps in the Log frame. Since they are not plugins, they don't load automatically when Leo starts. I don't find that to be a problem, since it's easy to provide a Leo command, button, or menu item to open them when you want to use them.
I open a tabbed app with the following command:
def toggle_app_tab(log, tabname, top_widget):
"""Create or remove our app's tab.
ARGUMENTS
log -- the log panel object for this outline.
tabname -- a string to use as the display name of our tab.
top_widget -- an instance of top level widget of our app.
"""
# If our tab is visible, remove it
if log.contentsDict.get(f'{tabname}-visible', False):
log.deleteTab(tabname)
log.contentsDict[f'{tabname}-visible'] = False
else:
# Show our tab, reusing our widget if already loaded
if log.contentsDict.get(f'{tabname}-loaded', False):
log.createTab(tabname,
widget = log.contentsDict[f'{tabname}-widget'],
createText = False)
log.contentsDict[f'{tabname}-visible'] = True
log.selectTab(tabname)
else:
# Create our tab for the first time
log.createTab(tabname, widget = w,
createText = False)
log.selectTab(tabname)
log.contentsDict[f'{tabname}-loaded'] = True
log.contentsDict[f'{tabname}-visible'] = True
log.contentsDict[f'{tabname}-widget'] = w
By "widget", I mean a PyQt widget. It will usually contain other GUI widgets and code. Here's how this function would typically be called. The widget does not need to have the signature shown here, but it's an obvious way to get Leo's key objects into the app.
log = c.frame.log
TABNAME = 'The App'
import theApp
w = theApp.MainWidget(g, c)
toggle_app_tab(log, TABNAME, w)
Notice that when we "remove" the app - meaning the app's tab is removed from the Log frame - we keep a reference to the main widget. This way, when we make the tab visible again, the app will have retained all its state and you can pick up where you left off.
I have attached a screen shot of one of my tabbed apps in session.