Closed goblin closed 5 months ago
This would seem to be unfortunate wording in the docs. If I recall correctly what is supported is TextType
, which is Text | str
. So you can use a Text
Rich renderable, or a string.
Yup, that's OK.
It's a bit of a pity though, DataTable seems to work fine with more generic Renderables (and shows the first row of the Table in this case):
from textual.app import App
from textual.widgets import DataTable
from rich.table import Table
class MyApp(App):
def compose(self):
subtab = Table('sub1', 'sub2')
subtab.add_row('it1', 'it2')
tab = DataTable()
tab.add_columns("Head1", "Head2")
tab.add_row(subtab, 'Item2')
yield tab
MyApp().run()
I'm trying to apply customization of the SelectionList Options based on the available width of the list, and it's tricky to do if Renderables aren't allowed.
Don't forget to star the repository!
Follow @textualizeio for Textual updates.
Issue
When trying to use a Rich Renderable, in form of a Rich Table, as a prompt for
SelectionList
like in this sample app:I'm getting an exception, and then another one:
While it may not make sense to use a multi-line Table as a SelectionList Option, it definitely shouldn't cause two exceptions like this. It also shows that under the hood, SelectionList actually expects Text, not just any Renderable.
Documentation
According to the docs, Rich Renderables should be allowed as SelectionList Options:
https://textual.textualize.io/widgets/selection_list/#examples:
When navigating to the Rich renderables link, we actually see Rich Table used as an example of a Rich Renderable, along with the fizzbuzz example.
Textual Diagnostics
Versions
Python
Operating System
Terminal
Rich Console options