How do I get buttons with a scroll bar
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 30/100
Research direction
Reproduce the provided full-screen example with the repeated pets list and the HSplit, VSplit, Window, Button, and Layout entry points shown. Check how oversized content is handled and determine the intended scrollbar behavior; done means the full button list remains navigable without the “Window is too small” failure while the result pane still works.
Written by the indexing model from the issue text.
Description
so I have this code
from prompt_toolkit.key_binding.bindings.focus import focus_next, focus_previous
from prompt_toolkit.layout.containers import VSplit, HSplit, Window
from prompt_toolkit.layout.controls import FormattedTextControl
from prompt_toolkit.key_binding import KeyBindings
from prompt_toolkit.widgets import Button
from prompt_toolkit.layout import Layout
from prompt_toolkit import Application
from functools import partial
pets = ['dog', 'cat', 'parrot']
buttons = []
kb = KeyBindings()
@kb.add('c-c')
def exit_(event):
event.app.exit()
sys.exit()
kb.add("tab")(focus_next)
kb.add("s-tab")(focus_previous)
formatted_text = FormattedTextControl("")
for pet in pets:
def handler(pet_name):
formatted_text.text = f'{pet_name} button clicked!'
btn = Button(pet, width=len(pet), handler=partial(handler, pet), left_symbol='', right_symbol='')
buttons.append(btn)
root_container = VSplit(
[
HSplit(buttons),
Window(width=1, char="|"),
Window(formatted_text)
],
padding=1
)
layout = Layout(root_container)
application = Application(layout=layout, key_bindings=kb, full_screen=True, mouse_support=True,)
application.run()
my problem is if I make the list bigger like pets = ['dog', 'cat', 'parrot']*100 it fails and gives "Window is too small". So I want to add a scrollbar next to it which allows me to scroll through the buttons, how do I do that?
- Dominant language
- Python
- Stars
- 10.6k
- Forks
- 815
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from prompt-toolkit/python-prompt-toolkit
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
prompt-toolkit/python-prompt-toolkit#2073 · 2 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
prompt-toolkit/python-prompt-toolkit#1154 · 1 comment ·
All issues in prompt-toolkit/python-prompt-toolkit
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
zostera/django-bootstrap4#894 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
use-agent-os/agent-os#3276 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
NousResearch/hermes-agent#117848 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
zilliztech/memsearch#759 ·