@vitalije first provided a script to expand the toolbar in https://github.com/leo-editor/leo-editor/issues/407Here is an update that works with PyQt6
@vitalije first provided a script to expand the toolbar in https://github.com/leo-editor/leo-editor/issues/407Here is an update that works with PyQt6
"""
Expand button bar
"""
from PyQt6.QtCore import QPointF, Qt
from PyQt6.QtGui import QMouseEvent
from PyQt6.QtWidgets import QApplication
pos = QPointF(0, 0)
button = Qt.MouseButton.LeftButton
btns = Qt.MouseButton(0)
mods = Qt.KeyboardModifier(0)
# Define the event types directly without accessing them through Qt
e1 = QMouseEvent(QMouseEvent.Type.MouseButtonPress, pos, button, btns, mods)
e2 = QMouseEvent(QMouseEvent.Type.MouseButtonRelease, pos, button, btns, mods)
# Assuming 'c' and 'w' are already defined
for w in c.frame.iconBar.w.children():
if w.objectName() == 'qt_toolbar_ext_button':
QApplication.sendEvent(w, e1)
QApplication.sendEvent(w, e2)
breakAgain thanks to Vitalije for the original script.
--
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 leo-editor+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/6590e9b3-9ffa-4ed8-ba38-cf403c4ed62fn%40googlegroups.com.
From original issue #407 - You can put that in @button expand-toolbar node in your myLeoSettings.leo under @buttons node.If it is first child of @buttons then this button will be on left side of toolbar and it will be easier to click this button and then to find button you need.I confirmed it also works for me as a script using Ctrl-B.
It took me a while to understand what the @button node is doing.
...
Alright, I think I understand the bounds of the problem.
Googling shows that the QToolbar class has inherent limitations. There is no way to split QToolButton widgets into separate rows. Happily, the toolbar shows an extension icon on the far right when there are too many buttons. Clicking this icon will show the remaining widgets on separate lines. The newly revealed icons remain visible until the user clicks the extension icon again.
I never noticed this behavior before. Worse, my dark theme obscured the extension icon! I've corrected that bug by giving the icon a lighter background color.
@button expand-toolbar
This script needs more explanation. The script creates a button that duplicates the purpose of the extension icon. The script (@button node) does nothing if everything in the icon bar is already visible.
The script simulates a single keypress (and release) on the extension icon. Therefore, the newly revealed icons will remain visible until the user presses the button (or the actual extension icon).
The test: if w.objectName() == 'qt_toolbar_ext_button':
looks for the name that Qt assigns to the expansion icon. This name has nothing to do with the headline of the @button node!
Summary
At long last, I understand the inherent limitations of the QToolbar widget. There seems to be no way to split its contents into separate (always visible) lines.
Otoh, the extension icon shows all widgets when clicked and continues to do so until clicked again. This behavior is good enough for most purposes.
I've corrected my dark theme to show the extension icon. The icon must not have a black background.
The given @button script works, but it needs some explanation. I'll amend #3851 accordingly.
Edward
It's not just a black background that hides it. There must be a css selector for it, mustn't there?
Googling shows that the QToolbar class has inherent limitations. There is no way to split QToolButton widgets into separate rows.
Better, I think: background-color: @text-foreground; This should work for any (dark) color theme. If you omit the #qt_toolbar_ext_button, the style will get applied to the menubar's "menu-indicator" also, as well as any other toolbar (yes, the menubar also has an overflow indicator, if you can see it). This is most likely what one wants.
Better, I think: background-color: @text-foreground; This should work for any (dark) color theme. If you omit the #qt_toolbar_ext_button, the style will get applied to the menubar's "menu-indicator" also, as well as any other toolbar (yes, the menubar also has an overflow indicator, if you can see it). This is most likely what one wants.