Replies: 1 comment 3 replies
-
| I can't think of a good reason to recompose an entire screen. You might want to elaborate on why you wanted to do that. That said, I suspect the issue is that you aren't awaiting  The fix is to make the handler async, and await  from textual.app import App, ComposeResult
from textual.reactive import reactive
from textual.events import Click
from textual.widgets import (
    Footer,
    Header,
    Placeholder,
)
from textual.screen import ModalScreen
class BarScreen(ModalScreen):
    BINDINGS = [("escape", "app.pop_screen", "Cancel")]
    bar: reactive[str] = reactive("init", recompose=True)
    def compose(self) -> ComposeResult:
        yield Header()
        yield Placeholder("bar")
        yield Footer()
class FooApp(App):
    BINDINGS = [
        ("q", "quit", "Quit"),
    ]
    def compose(self) -> ComposeResult:
        yield Header()
        yield Placeholder("foo")
        yield Footer()
    async def on_click(self, event: Click) -> None:
        screen = BarScreen()
        await self.push_screen(screen)
        screen.bar = "foo"
if __name__ == "__main__":
    app = FooApp()
    app.run()
    ``` | 
Beta Was this translation helpful? Give feedback.
                  
                    3 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
In a
ModalScreensubclass, I defined a reactive attribute withrecompose=True. If I set this attribute after callingApp.push_screen(screen), theHeaderwidget crashes unexpectedly. I'm not sure whether this is a bug or a misuse on my part. Would appreciate any guidance or clarification.This is the traceback:

This is test code:
Beta Was this translation helpful? Give feedback.
All reactions