Giter Club home page Giter Club logo

Comments (12)

davep avatar davep commented on June 22, 2024 1

I've not dived onto the why of this yet, but this doesn't seem to be anything to do with RadioSet in particular. The same effect can be achieved with Label or Button, for example.

from textual.

davep avatar davep commented on June 22, 2024 1

I wonder if this is actually another instance of #4360.

from textual.

TomJGooding avatar TomJGooding commented on June 22, 2024

This looks to me like the effect of a widget with 100% width (i.e. the Input) inside a container with a width of 1fr?

Here's a slighlly reduced example. Compare before and after uncommenting the CSS on line 16:

from textual.containers import Container, ScrollableContainer
from textual.widgets import Input, Button

from textual.app import App, ComposeResult


class ExampleApp(App):
    CSS = """
    #outer {
        border: solid red;
    }

    #inner {
        margin-right: 20;
        border: solid blue;
        /* width: 100%; */
    }
"""

    def compose(self) -> ComposeResult:
        with ScrollableContainer(id="outer"):
            yield Button()
            with Container(id="inner"):
                yield Input()


if __name__ == "__main__":
    app = ExampleApp()
    app.run()

from textual.

TomJGooding avatar TomJGooding commented on June 22, 2024

It took me a minute to figure out why changing the width then wasn't working in your example above, but it looks like your CSS was missing the parent selector like this:

class MyTabPane(TabPane):
    DEFAULT_CSS = """
    MyTabPane Grid {

I confess I don't understand why the rest of the CSS still seems to work though! I'm still not caught up on nested CSS so not sure if this might have revealed some sort of bug...?

from textual.

jakubziebin avatar jakubziebin commented on June 22, 2024

Honestly it looks like a workaround to me..., because what is the reason why width: 1fr causes the margin-right to not work properly? IMO it's a common case that a widget with width: 100% is mounted inside a container with width: 1fr and I don't see any reason why this margin would not work in this case. Please correct me if I am wrong.

from textual.

jakubziebin avatar jakubziebin commented on June 22, 2024

Yes, thanks for your help! I look forward to the solution.

from textual.

jakubziebin avatar jakubziebin commented on June 22, 2024

IMO, worth knowing, we observed this problem on version 0.52.1.

from textual.

davep avatar davep commented on June 22, 2024

Ahh, okay, likely not related then.

from textual.

TomJGooding avatar TomJGooding commented on June 22, 2024

Just to clarify, there was a change in this margin behaviour but back in v0.48.0 following #4037.

@jakubziebin I was only trying to clarify the likely cause with a MRE (as actually nothing to do with a RadioSet). I'm not saying this behaviour is correct or incorrect (and as you'll see from the discussion in the PR above, margin behaviour is a bit of a contentious issue!)

from textual.

jakubziebin avatar jakubziebin commented on June 22, 2024

I encountered one more strange behavior of the margin:

from textual.app import App, ComposeResult
from textual.widgets import Static, Input, Button
from textual.containers import Container


class MyContainer(Container):
    DEFAULT_CSS = """
    MyContainer {
        height: auto;
        #content {
            height: auto;
            background: $panel;
        }
    
        #container-with-button {
            align: center middle;
            height: auto;
        }
        
        Input {
            margin-bottom: 1;
        }
    }
    """

    def compose(self) -> ComposeResult:
        with Container(id="content"):
            yield Static("Example static")
            yield Input()
            with Container(id="container-with-button"):
                yield Button("Click me")


class MyApp(App):
    def compose(self) -> ComposeResult:
        yield MyContainer()


MyApp().run()

Part of the button is cut off because of the bottom margin of the input. I wasn't sure if this should be posted in another issue, but I thought it was somewhat related, let me know if it should be converted to another issue.

from textual.

TomJGooding avatar TomJGooding commented on June 22, 2024

Part of the button is cut off because of the bottom margin of the input.

I don't think it is the margin. If you try deleting the CSS for the Input from your example, you'll see the button is still cut off.

Looks to me something about the middle alignment throwing off the sizing.

EDIT: Interestingly, if you add a second Button all seems to work as expected.

from textual.app import App, ComposeResult
from textual.containers import Container
from textual.widgets import Button


class ExampleApp(App):
    CSS = """
    #outer-container {
        height: auto;
        border: solid red;
    }

    #btn-container {
        /* align: center middle; */
        height: auto;
        border: solid blue;
    }
    """

    def compose(self) -> ComposeResult:
        with Container(id="outer-container"):
            with Container(id="btn-container"):
                yield Button()
                # yield Button()


if __name__ == "__main__":
    ExampleApp().run()

from textual.

github-actions avatar github-actions commented on June 22, 2024

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

from textual.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.