SelectionList empty #5415
-
Hey! After a look at the tutorial, I'm trying to create a minimal program with a from textual.app import App, ComposeResult
from textual.widgets import Footer, Header, SelectionList
from textual.widgets.selection_list import Selection
class Tags(SelectionList[int]):
def compose(self) -> ComposeResult:
yield SelectionList[int](
# *[(f"Option: {i}", i) for i in range(10)]
Selection("Wat", 0, True),
Selection("Meh", 1)
)
class ExampleApp(App):
"""A tui with a SelectionList."""
def compose(self) -> ComposeResult:
yield Header()
yield Tags()
yield Footer()
if __name__ == "__main__":
app = ExampleApp()
app.run() This gives me the following output: As you can see, my options don't appear. If I run the Can somebody spot what I'm missing here? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The problem is that you're trying to compose a If you want your widget to be a subclass of class MySelectionList(SelectionList):
def __init__(self) -> None:
selections = [("First", 1), ("Second", 2)]
super().__init__(*selections) |
Beta Was this translation helpful? Give feedback.
The problem is that you're trying to compose a
SelectionList
inside anotherSelectionList
, which isn't going to work.If you want your widget to be a subclass of
SelectionList
, you can initialize it usingsuper().__init__()
and pass in your options: