Comments (12)
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.
I wonder if this is actually another instance of #4360.
from textual.
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.
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.
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.
Yes, thanks for your help! I look forward to the solution.
from textual.
IMO, worth knowing, we observed this problem on version 0.52.1
.
from textual.
Ahh, okay, likely not related then.
from textual.
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.
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.
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.
Don't forget to star the repository!
Follow @textualizeio for Textual updates.
from textual.
Related Issues (20)
- Add tooltips to all input widgets HOT 1
- How to change text background on button click HOT 2
- CancelledError stack trace in terminal after quitting app with Ctrl+C HOT 2
- `on_leave` event being fired by widget in inactive screen
- pageup and pagedown bindings not firing on `main` branch HOT 6
- Memray's test suite deadlocks with Textual 0.65.2 HOT 3
- New default key bindings for DataTable override app-defined bindings HOT 3
- priority binding order is not respected in the Footer HOT 3
- Method to add content to Content Switcher HOT 5
- Memray's test suite fails due to a deadlock with Textual 0.67.1 HOT 7
- Possible deadlock with the ToastRack and Tooltip that appeared out of nowhere HOT 3
- Clicking off the Select dropdown causes a crash in `update_focus` HOT 8
- v0.68.0 test_deadlock is failing HOT 12
- Some minor documentation additions HOT 3
- Add Image support using imgcat HOT 6
- Callback is not called when Screen is dismissed HOT 13
- `Tree.select_node` doesn't select the node, it highlights it
- Using standard python logger HOT 1
- Documentation is not up-to-date HOT 3
- Travel back in time to 1900 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from textual.