textual
textual copied to clipboard
Extraneous padding when using inline mode
This might be on purpose, but I'd prefer to control padding on my own :D
Reproduction:
from textual.app import App, ComposeResult
from textual.widgets import Header, Footer, Button, Static
class SimpleApp(App):
BINDINGS = [("q", "quit", "Quit")]
def compose(self) -> ComposeResult:
yield Button("Click me!", id="message")
if __name__ == "__main__":
app = SimpleApp()
app.run(inline=True)
Result:
Meanwhile I get this in non inline mode:
Thank you for your issue. Give us a little time to review it.
PS. You might want to check the FAQ if you haven't done so already.
This is an automated reply, generated by FAQtory
AFAIK this is intentional, but I completely agree with this issue (also I think this has come up a couple of times now).
My app by default has padding so it meant that to run it on inline mode I had to write extra CSS to remove it but only while on inline mode.
I think it's always better to give the user what they'd expect (no unexpected padding) and then let them add it if they decide it looks better.
It's actually border, not padding. You can remove it with the following:
Screen:inline {
border: none;
}
that worked, thanks!
there's only one new line which I'd like to remove :D
I think it's always better to give the user what they'd expect (no unexpected padding) and then let them add it if they decide it looks better.
I think you are giving the average dev too much credit in knowing what looks better. You and Patrick may have an eye for aesthetics, but most devs will stick with the default look and feel 99% of the time.
I agree, it's good to have decent defaults 😊
By the way I have found where that newline is added: https://github.com/Textualize/textual/blob/56a3367b14b663889b0901e0f35720ced28c7c12/src/textual/drivers/linux_inline_driver.py#L187
This was added to fix this: https://github.com/Textualize/textual/issues/4385, but from a quick test it doesn't seem that removing that print shows the issue (at least on my terminal)
https://github.com/user-attachments/assets/485a9f91-667c-403e-b537-8fd3fb829e88
Ah ok, I didn't spot that it was a border. I still don't think it looks better though 🤷
there's only one new line which I'd like to remove :D
This is the thing I was thinking of that I've seen mentioned a few times and would also like to remove, as it just looks janky to me unless your terminal background happens match your app background colour. If it doesn't, this space just looks like a bug.
Textual v0.80.0 added an INLINE_PADDING attribute to the App which hopefully resolves this issue?
from textual import __version__
from textual.app import App, ComposeResult
from textual.widgets import Static
class ExampleApp(App):
CSS = """
Screen:inline {
border: none;
}
"""
INLINE_PADDING = 0
def compose(self) -> ComposeResult:
yield Static(f"This is a single-line app in Textual v{__version__}!")
if __name__ == "__main__":
app = ExampleApp()
app.run(inline=True)