textual icon indicating copy to clipboard operation
textual copied to clipboard

Extraneous padding when using inline mode

Open patrick91 opened this issue 1 year ago • 7 comments

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:

CleanShot 2024-08-14 at 11 41 09

Meanwhile I get this in non inline mode:

CleanShot 2024-08-14 at 11 42 04

patrick91 avatar Aug 14 '24 09:08 patrick91

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

github-actions[bot] avatar Aug 14 '24 09:08 github-actions[bot]

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.

darrenburns avatar Aug 14 '24 09:08 darrenburns

It's actually border, not padding. You can remove it with the following:

Screen:inline {
    border: none;
}

willmcgugan avatar Aug 14 '24 10:08 willmcgugan

that worked, thanks!

CleanShot 2024-08-14 at 12 04 21

there's only one new line which I'd like to remove :D

patrick91 avatar Aug 14 '24 10:08 patrick91

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.

willmcgugan avatar Aug 14 '24 10:08 willmcgugan

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

patrick91 avatar Aug 14 '24 10:08 patrick91

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.

darrenburns avatar Aug 14 '24 10:08 darrenburns

Textual v0.80.0 added an INLINE_PADDING attribute to the App which hopefully resolves this issue?

image

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)

TomJGooding avatar Sep 24 '24 16:09 TomJGooding

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

github-actions[bot] avatar Sep 24 '24 16:09 github-actions[bot]