Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REQUEST] Default padding for panels #385

Closed
Edward-Knight opened this issue Oct 14, 2020 · 4 comments
Closed

[REQUEST] Default padding for panels #385

Edward-Knight opened this issue Oct 14, 2020 · 4 comments
Labels
accepted Task was accepted

Comments

@Edward-Knight
Copy link
Contributor

How would you improve Rich?

At the moment panels have no default padding:

>>> from rich import print
>>> from rich.panel import Panel
>>> print(Panel.fit("Hello World!"))
╭────────────╮
│Hello World!│
╰────────────╯

I propose adding a default left and right padding to make the output more aesthetically pleasing:

>>> print(Panel.fit("Hello World!", padding=(0, 1)))
╭──────────────╮
│ Hello World! │
╰──────────────╯

A quirk of most monospace fonts and how characters are often printed in the terminal, means that a padding of (0, 1) gives a more even padding than (0, 0).

What problem does it solved for you?

This can be solved by the user by simply suppling the padding parameter as I have above.

I am aware that this may just be a suggestion to change the default to my personal preference, but I feel that this extra padding means the edge of the text is more evenly centred in the panel than the current default. This would make the default behaviour of rich closer to the default behaviour of many other tools, for example:

HTML <input> box (on Chrome):
image

HTML <input> box (on Firefox):
image

Microsoft Word Text Box:
image

@willmcgugan
Copy link
Collaborator

Ok, that seems reasonable.

@willmcgugan willmcgugan added accepted Task was accepted and removed Needs triage labels Oct 15, 2020
@Edward-Knight
Copy link
Contributor Author

Great! I'll put together a small MR later today hopefully

@willmcgugan
Copy link
Collaborator

No, need. It's already in my local branch. Should be in v9.0.0

@willmcgugan
Copy link
Collaborator

v9.0.0 is in PyPi now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Task was accepted
Projects
None yet
Development

No branches or pull requests

2 participants