Skip to content

Stuck on synching widget's data. #5527

Answered by TomJGooding
V205Arduino asked this question in Q&A
Discussion options

You must be logged in to vote

The MarkdownViewer widget doesn't have a reactive text attribute. You'll need to use the update method of the underlying Markdown widget:

from textual.app import App, ComposeResult
from textual.widgets import MarkdownViewer, TextArea


class MarkdownEditor(App):
    def compose(self) -> ComposeResult:
        yield TextArea.code_editor(language="markdown")
        yield MarkdownViewer(show_table_of_contents=True)

    def on_text_area_changed(self, event: TextArea.Changed) -> None:
        self.query_one(MarkdownViewer).document.update(event.text_area.text)


if __name__ == "__main__":
    app = MarkdownEditor()
    app.run()

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@V205Arduino
Comment options

Answer selected by V205Arduino
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants