Skip to content
Discussion options

You must be logged in to vote

Widgets do have a mount method which will "Mount widgets below this widget (making this widget a container)."

Here's a quick example:

from textual.app import App, ComposeResult
from textual.widget import Widget
from textual.widgets import DataTable, Label


class CustomWidget(Widget):
    def compose(self) -> ComposeResult:
        yield DataTable()

    def on_mount(self) -> None:
        table = self.query_one(DataTable)
        table.add_columns(*[f"Col {i}" for i in range(5)])
        for j in range(5):
            table.add_row(*["Click Me!"] * 5, label=f"Row {j}")

    def on_data_table_cell_selected(
        self,
        event: DataTable.CellSelected,
    ) -> None:
        self.m…

Replies: 3 comments 16 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@willmcgugan
Comment options

@zhajio1988
Comment options

Comment options

You must be logged in to vote
14 replies
@TomJGooding
Comment options

Answer selected by zhajio1988
@zhajio1988
Comment options

@TomJGooding
Comment options

@zhajio1988
Comment options

@TomJGooding
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants