-
Notifications
You must be signed in to change notification settings - Fork 815
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
Grid columns with multiple units resolves percent unit to wrong value #1406
Comments
A similar application containing a # relative_sizes.py
from textual.app import App
from textual.containers import Horizontal
from textual.widgets import Label
class MyApp(App):
def compose(self):
yield Horizontal(
Label("1fr", classes="fr"),
Label("width = 16", classes="fixed"),
Label("middle", classes="percent"),
Label("1fr", classes="fr"),
Label("width = 16", classes="fixed"),
)
app = MyApp(css_path="relative_sizes.css") /* relative_sizes.css */
Label {
border: round white;
content-align-horizontal: center;
height: 100%;
}
Label.fr {
width: 1fr;
}
Label.fixed {
width: 16;
}
Label.percent {
width: 25%;
} |
Printing the values of textual/src/textual/layouts/grid.py Line 25 in cc1f2f6
shows that the unit
The screen recording below proves this, as making the terminal taller makes the middle column wider: Screen.Recording.2023-01-23.at.10.32.37.mov |
Investigating this issue showed that there were two bugs related to the relative dimension that the scalars in On the one hand, the method textual/src/textual/css/_styles_builder.py Line 875 in 383ab18
Not only are the full names On the other hand, |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
In a grid layout with mixed units in the style
grid-columns
, the column associated with25%
gets the wrong size.However, using
25w
or25vw
instead of25%
produces the correct result.Here is the screenshot of the app where the middle column should take up 25% of the total width and the 1st and 4th columns should accommodate that:
grid_columns.py
grid_columns.css
Try running the app with
textual run --dev grid_columns.css
and change the value25%
to25w
or25vw
and notice it gets set to the correct value.The text was updated successfully, but these errors were encountered: