prompt-toolkit / python-prompt-toolkit

Library for building powerful interactive command line applications in Python
https://python-prompt-toolkit.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
9.37k stars 716 forks source link

Frame top and bottom row overexpanding #1668

Open FancyNeuron opened 2 years ago

FancyNeuron commented 2 years ago

Hi there,

Thanks for your amazing library. I just noticed something that looks a lot like a bug

root_container = Frame(Window(height=2, width=3))
layout = Layout(root_container)

app = Application(layout=layout)
app.run()

When I run this, I get this rendered to the screen:

┌─────────────────────────────────────────────────────────────────────────────────────────────────┐
│   │
│   │
└─────────────────────────────────────────────────────────────────────────────────────────────────┘

prompt_toolkit version: 3.0.31 python 3.10 Windows 10

Thanks!

joouha commented 2 years ago

The way the Frame widget is written, the top and bottom rows will expand to fill the available width, while the body fits to the width of the contents.

You can work around this by wrapping your frame in a Box widget, and allowing the Box to fill the space to the right of the Frame:

root_container = Box(Frame(Window(height=2, width=3)), padding=0, padding_right=None)
┌───┐
│   │
│   │
└───┘