prompt-toolkit / prompt-toolkit/python-prompt-toolkit
Limiting application width
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.6k
- Forks
- 815
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying to specify a maximum width for my application's root container to avoid long lines in large terminals. I'm using an HSplit for the root container. Its width parameter does nothing unless I wrap it in a VSplit.
Is this a bug or am I misunderstanding how this should work?
Here's a simple demo:
from prompt_toolkit.application import Application
from prompt_toolkit.key_binding import KeyBindings
from prompt_toolkit.layout import Layout
from prompt_toolkit.layout.containers import HSplit, VSplit, Window
from prompt_toolkit.layout.controls import FormattedTextControl
from prompt_toolkit.styles import Style
style = Style([('text', 'bg:#a0a0a0 fg:#000000')])
root_container = HSplit(
width=20,
children=[
Window(FormattedTextControl('Hello'),
style='class:text',
dont_extend_width=True),
],
)
# This extends root_container's width beyond 20
layout = Layout(
root_container
)
# This limits root_container's width to 20
layout = Layout(
VSplit([root_container])
)
kb = KeyBindings()
@kb.add('c-c')
def _(event):
event.app.exit(1)
app = Application(layout=layout,
key_bindings=kb,
style=style)
app.run()
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.
Research direction
Run the provided Python demo first, then read the Layout, HSplit, VSplit, and Window entry points to trace how the root container receives its width. Done when it is clear whether this is intended and, if not, the demo's root HSplit respects the requested 20-column limit.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100