I started using some advanced features of Leo in "real life" and here is my first customization attempt :)
The problem is: I created so much buttons in iconbar, that they don't fit in a single row. By default the iconbar has only single row and can be expanded for a moment with a ">>" button on the right side. But then it becomes single-row again. I did not find a simple solution to make iconbar stay multirow, only a deprecated "toolbar" plugin for Tk GUI, but not for Qt. So I had to make some customizations. The following code is mainly based on stackoverflow
solution.
This solution is a little bit 'hacky', but it's advantage that it does not change any code of iconbar in Leo codebase.
Everything together is attached in .py file (execute with ctrl+b)
First, expand iconbar:
from leo.core.leoQt import QtWidgets, QtCore
iconbar=c.frame.iconBar.w
lay = iconbar.findChild(QtWidgets.QLayout)
if lay is not None:
lay.setExpanded(True)
Second, hide ">>" button:
button = iconbar.findChild(QtWidgets.QToolButton, "qt_toolbar_ext_button")
if button is not None:
button.setFixedSize(0, 0)
Third, override "Leave" event (triggered when mouse leaves iconbar):
class eventfilterinst(QtCore.QObject):
def eventFilter(self, obj, event):
if event.type() == QtCore.QEvent.Leave: # and obj is qt_widget:
return True
return super().eventFilter(obj, event)
ieventfilterinst=eventfilterinst()
c.frame.iconBar.w.installEventFilter(ieventfilterinst)
Now, the iconbar will stay expanded. But when expanded it overlaps body and tree widgets, so enlarge it:
c.frame.iconBar.w.setFixedHeight(100)
The problem is that this behavior will reset when outline is saved, so register a Leo event handler:
def expandiconbar(tag, keywords):
global ieventfilterinst
# the same code as above
iconbar=c.frame.iconBar.w
lay = iconbar.findChild(QtWidgets.QLayout)
if lay is not None:
lay.setExpanded(True)
ieventfilterinst=eventfilterinst()
c.frame.iconBar.w.installEventFilter(ieventfilterinst)
g.registerHandler('save2',expandiconbar)
I share this for everyone who is concerned about the same problem.
Any comments are welcome!