Remove padding from DataTable? #2503
Answered
by
davep
TomJGooding
asked this question in
Q&A
-
Is it possible to remove the padding in a DataTable? For example, how might you display this as a solid block rather than stripes? from textual.app import App, ComposeResult
from textual.widgets import DataTable
BLOCK = "\u2588" * 2
ROWS = [[BLOCK] * 10] * 11
class ExampleApp(App):
CSS = """
Screen {
align: center middle;
}
DataTable {
width: auto;
}
"""
def compose(self) -> ComposeResult:
yield DataTable()
def on_mount(self) -> None:
table = self.query_one(DataTable)
table.show_header = False
table.show_cursor = False
table.add_columns(*ROWS[0])
table.add_rows(ROWS[1:])
if __name__ == "__main__":
app = ExampleApp()
app.run() |
Beta Was this translation helpful? Give feedback.
Answered by
davep
May 6, 2023
Replies: 1 comment 2 replies
-
That padding is baked in by the looks of things. As to the wider question: I probably wouldn't use a |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
TomJGooding
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That padding is baked in by the looks of things.
As to the wider question: I probably wouldn't use a
DataTable
to start with. Perhaps there's a more appropriate method of doing what you want to do here? (outside of any other context, for example, I think I'd be more inclined to roll a widget using the line API).