Need help with Button width sizing within a Container #1286
-
I have a Container with two Buttons and a Label in the middle. I'm not able to affect the Button width, even if I set it to from textual.app import App, ComposeResult
from textual.containers import Container
from textual.widgets import Button, Label
class ButtonWidth(App):
CSS = '''
#question_container {
max-height: 4;
}
#previous {
dock: left;
width: 0;
}
#next {
dock: right;
width: 0;
}
#question {
border: blank;
}
'''
def compose(self):
q = 'Q1) Display the first five lines for the input file ip.txt'
yield Container(Button(label='←', id='previous'),
Label(q, id='question'),
Button(label='→', id='next'),
id='question_container')
def on_mount(self):
self.dark = False
if __name__ == '__main__':
app = ButtonWidth()
app.run() Partial screenshot for the above code: I want to reduce the Button width just enough to fit the single character. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
From memory, I think buttons have a min-width which you will also have to adjust. BTW I think you can print widget.styles.css to see the actual css applied to a widget. |
Beta Was this translation helpful? Give feedback.
-
Thanks, using Button {
width: 16;
} Also, good to know about printing actual css for debug purposes. |
Beta Was this translation helpful? Give feedback.
From memory, I think buttons have a min-width which you will also have to adjust.
BTW I think you can print widget.styles.css to see the actual css applied to a widget.