Minimal Code example for plugin which can add widget to a pane

36 views
Skip to first unread message

john lunzer

unread,
Apr 28, 2015, 6:56:15 AM4/28/15
to leo-e...@googlegroups.com
I'm trying to slosh through bookmarks.py and hack it up to give me my own plugin which can add a widget to a pane. 

I'm sure this isn't the best way to go about this and I was wondering if there was a minimal example to show how to achieve a plugin that can be added to a pane. I would be grateful for the help.

Terry Brown

unread,
Apr 28, 2015, 9:47:59 AM4/28/15
to leo-e...@googlegroups.com
Regarding adding widgets and ignoring plugins, maximally minimal would
be:

from leo.core.leoQt import QtWidgets
w = QtWidgets.QSlider()
c.free_layout.get_top_splitter().addWidget(w)

Adds slider widget, probably on right hand side, not that noticeable,
you could miss it ;-)

w can be anything of course, a QWidget with a layout containing lots of
other widgets, for example. To make your widget addable from the super
secret right-click on the pane dividers context menu, you need to
implement the "provider" interface defined here:

file://{{g.getBaseDirectory(c)}}/LeoPyRef.leo#Code-->Qt%20gui-->@file%20../plugins/nested_splitter.py-->class%20NestedSplitter%20(QSplitter)-->register_provider

I've posted examples here:
https://github.com/leo-editor/snippets/blob/master/examples/demo_widget.py
(the example is correct, the file:// link is missing some parameters
for the ns_do_context() method)

Cheers -Terry

john lunzer

unread,
Apr 29, 2015, 6:17:16 AM4/29/15
to leo-e...@googlegroups.com
Thanks for this Terry, it should be helpful to a lot of newcomers.

Edward K. Ream

unread,
Apr 29, 2015, 6:56:25 AM4/29/15
to leo-editor
On Tue, Apr 28, 2015 at 8:47 AM, 'Terry Brown' via leo-editor <leo-e...@googlegroups.com> wrote:

​Thanks for this.

Leo's home page now has a link to the snippets page in the left sidebar.

Edward
Reply all
Reply to author
Forward
0 new messages