I am trying to make a Container scrollable using ScrollablePane.But I can't scroll either with mouse or keyboard
from prompt_toolkit.layout.controls import FormattedTextControl
from prompt_toolkit import Application
from prompt_toolkit.layout import ScrollablePane
from prompt_toolkit.layout.layout import Layout
from prompt_toolkit.layout.containers import HSplit, VSplit, Window
content = HSplit(
[
VSplit(
[Window(FormattedTextControl('First Column')),
Window(FormattedTextControl('Second Column'))
]),
VSplit(
[Window(FormattedTextControl('First Column')),
Window(FormattedTextControl('Second Column'))
]),
VSplit(
[Window(FormattedTextControl('First Column')),
Window(FormattedTextControl('Second Column'))
]),
])
container = ScrollablePane(content=content)
app = Application(layout=Layout(container), full_screen=True)
app.run()
First, you should enable
mouse_support
inapp
:That does not actually seem to make the
ScrollablePane
scrollable with the mousewheel or using the arrows. I have yet to find a solution for this.I have found that stacking a bunch of focusable elements (e.g.
Window
) within theScrollablePane
and assigning a keyboard shortcut to change the app focus from one element to the next will scroll the pane.Example (decrease window height or increase
number
to obscure part of the display):