-
Notifications
You must be signed in to change notification settings - Fork 815
New issue
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
Callback is not called when Screen is dismissed #4656
Comments
I cannot reproduce this. You say you can't see the print statement, but does the app exit if you click the Quit button? Could you please paste the results of |
Just to back up what Will says, it's working perfectly fine for my with 0.68.0. As a self-contained example for you to try, complete with very visual feedback: from textual import on
from textual.app import App, ComposeResult
from textual.screen import Screen
from textual.widgets import Button
class Test(Screen[str]):
def compose(self) -> ComposeResult:
yield Button("Yes", id="Yes")
yield Button("No", id="No")
@on(Button.Pressed)
def test_the_callback(self, event: Button.Pressed) -> None:
assert event.button.id is not None
self.dismiss(event.button.id)
class ScreenCallbackTest(App[None]):
def compose(self) -> ComposeResult:
yield Button("Test")
@on(Button.Pressed)
def test_screen_callback(self) -> None:
def show_result(result: str) -> None:
self.notify(result)
self.push_screen(Test(), callback=show_result)
if __name__ == "__main__":
ScreenCallbackTest().run() Can you confirm either way what happens for you with that code? |
Textual DiagnosticsVersions
Python
Operating System
Terminal
Rich Console options
|
@davep Your example works fine. But the documentation example doesn't work. Dialog is dismissed and if I select 'Quit' the app doesn't quit. |
@villekr If I run |
Confirmed the behaviour with a new project, which only had textual dependency. Tested both with iTerm2 and macOS built-in terminal app. Same results with both. 0.62.0 - callback is called So definitely and consistently seems to be broken based on my tests. |
Have you upgraded Textual and Textual-dev ? i.e. |
@villekr How are you invoking the quit? Are you pressing the key I'm going to guess the latter. @willmcgugan Can you try the same with |
Ok, I see it if I click the footer and not if I press q! |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
Fixed in v0.69.0 |
Excellent work and super fast fix! Thank you! 0.69.0 confirmed working. |
Screen dismiss callback is not called. Confirmed with the documentation example and by adding print statement to callback function.
https://textual.textualize.io/guide/screens/#returning-data-from-screens
works as expected in 0.62.0 -> print statement in the console
broken from 0.63.0 up to latest 0.68.0 -> no print statement in the console
Kind of critical bug. If callback is not anymore supported then please update the documentation and dismiss function accordingly.
The text was updated successfully, but these errors were encountered: