-
-
Notifications
You must be signed in to change notification settings - Fork 993
Closed
Description
Given this code:
from textual.app import App, ComposeResult
from textual.widgets import ProgressBar
class WideBarApp(App[None]):
CSS = """
ProgressBar Bar {
width: 1fr;
}
"""
def compose(self) -> ComposeResult:
yield ProgressBar()
if __name__ == "__main__":
WideBarApp().run()
Up until Textual 4.x, it ran fine. As of Textual 5.0 it causes the following crash (trimmed to the last bit, because the traceback ends up being way too big for a GitHub issue; to the point that it refuses to accept it):
│ /Users/davep/temp/wide-bar/.venv/lib/python3.11/site-packages/textual/widgets/_progress_bar.py:100 in render │
│ │
│ 97 │ def render(self) -> RenderResult: │
│ 98 │ │ """Render the bar with the correct portion filled.""" │
│ 99 │ │ if self.percentage is None: │
│ ❱ 100 │ │ │ return self.render_indeterminate() │
│ 101 │ │ else: │
│ 102 │ │ │ bar_style = ( │
│ 103 │ │ │ │ self.get_component_rich_style("bar--bar") │
│ │
│ ╭─────── locals ───────╮ │
│ │ self = Bar(id='bar') │ │
│ ╰──────────────────────╯ │
│ │
│ /Users/davep/temp/wide-bar/.venv/lib/python3.11/site-packages/textual/widgets/_progress_bar.py:128 in │
│ render_indeterminate │
│ │
│ 125 │ │ else: │
│ 126 │ │ │ speed = 30 # Cells per second. │
│ 127 │ │ │ # Compute the position of the bar. │
│ ❱ 128 │ │ │ start = (speed * self._clock.time) % (2 * total_imaginary_width) │
│ 129 │ │ │ if start > total_imaginary_width: │
│ 130 │ │ │ │ # If the bar is to the right of its width, wrap it back from right to le │
│ 131 │ │ │ │ start = 2 * total_imaginary_width - start # = (tiw - (start - tiw)) │
│ │
│ ╭─────────────── locals ────────────────╮ │
│ │ highlighted_bar_width = 0.0 │ │
│ │ self = Bar(id='bar') │ │
│ │ speed = 30 │ │
│ │ total_imaginary_width = 0.0 │ │
│ │ width = 0 │ │
│ ╰───────────────────────────────────────╯ │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
ZeroDivisionError: float modulo
NOTE: 1 of 2 errors shown. Run with textual run --dev to see all errors.
Metadata
Metadata
Assignees
Labels
No labels