We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OptionList
width: auto
get_content_width
This code:
from textual.app import App, ComposeResult from textual.widgets import OptionList class OptionListAutoCrash(App[None]): CSS = """ OptionList { width: auto; } """ def compose(self) -> ComposeResult: yield OptionList() if __name__ == "__main__": OptionListAutoCrash().run()
results in this crash:
│ /Users/davep/temp/x/.venv/lib/python3.13/site-packages/textual/widgets/_option_list.py:396 in get_content_width │ │ │ │ 393 │ │ """Get maximum width of options.""" │ │ 394 │ │ console = self.app.console │ │ 395 │ │ options = console.options │ │ ❱ 396 │ │ return max( │ │ 397 │ │ │ Measurement.get(console, options, option.prompt).maximum │ │ 398 │ │ │ for option in self._options │ │ 399 │ │ ) │ │ │ │ ╭─────────────────────────── locals ────────────────────────────╮ │ │ │ console = <console width=153 ColorSystem.TRUECOLOR> │ │ │ │ container = Size(width=149, height=66) │ │ │ │ options = ConsoleOptions( │ │ │ │ │ size=ConsoleDimensions( │ │ │ │ │ │ width=153, │ │ │ │ │ │ height=68 │ │ │ │ │ ), │ │ │ │ │ legacy_windows=False, │ │ │ │ │ min_width=1, │ │ │ │ │ max_width=153, │ │ │ │ │ is_terminal=True, │ │ │ │ │ encoding='utf-8', │ │ │ │ │ max_height=68, │ │ │ │ │ justify=None, │ │ │ │ │ overflow=None, │ │ │ │ │ no_wrap=False, │ │ │ │ │ highlight=None, │ │ │ │ │ markup=None, │ │ │ │ │ height=None │ │ │ │ ) │ │ │ │ self = OptionList() │ │ │ │ viewport = Size(width=153, height=68) │ │ │ ╰───────────────────────────────────────────────────────────────╯ │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ValueError: max() iterable argument is empty
The text was updated successfully, but these errors were encountered:
fix(option list): fix crash on empty option list with auto width
15d8efe
Fixes Textualize#5489.
Successfully merging a pull request may close this issue.
This code:
results in this crash:
Textual Diagnostics
Versions
Python
Operating System
Terminal
Rich Console options
The text was updated successfully, but these errors were encountered: