-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
Description
The bug
Changing the background of a Markdown Widget dynamically via code is not changing the background of all Markdown Segments accordingly. Also see example screenshot, where the code segment is still the previous color.
Changing the background via tcss works properly.
MRE:
from textual.app import App, ComposeResult
from textual.widgets import Markdown, Select
EXAMPLE_MARKDOWN = """\
# Markdown Viewer
This is an example of Textual's `MarkdownViewer` widget.
## Features
Markdown syntax and extensions are supported.
- Typography *emphasis*, **strong**, `inline code` etc.
- Headers
## Tables
Tables are displayed in a DataTable widget.
| Name | Type | Default | Description |
| --------------- | ------ | ------- | ---------------------------------- |
| `show_header` | `bool` | `True` | Show the table header |
| `fixed_rows` | `int` | `0` | Number of fixed rows |
## Code Blocks
Code blocks are syntax highlighted.
"""
class MarkdownExampleApp(App):
def compose(self) -> ComposeResult:
yield Select.from_values(["red", "green", "blue"])
markdown_viewer = Markdown(EXAMPLE_MARKDOWN)
yield markdown_viewer
def on_select_changed(self, event: Select.Changed):
self.query_one(Markdown).styles.background = event.value
if __name__ == "__main__":
app = MarkdownExampleApp()
app.run()
Metadata
Metadata
Assignees
Labels
No labels