Open JoeZiminski opened 2 hours ago
I'm not sure what may have changed, but why use a lambda rather than call_after_refresh(self.dismiss, True)
?
EDIT: Never mind, after taking a closer look I think this changed in #4789 with the warning below added to the dismiss
docs. But I'm also struggling to understand this warning and the error message in the context of dismissing a screen after it has refreshed.
Textual will raise a ScreenError if you await the return value from a message handler on the Screen being dismissed. If you want to dismiss the current screen, you can call self.dismiss() without awaiting.
I just wanted to highlight change in behaviour that I could not see documented in the change log. Previously I was calling
call_after_refresh(lambda: self.dismiss(True))
within aModalScreen
. Now, this gives an error:ScreenError: Can't await screen.dismiss() from the screen's message handler; try removing the await
I think because of a new check where this error is raised. I found another workaround to acheive what I wanted, but thought I'd raise this in case 1) this change in behaviour was not intended 2) an improved error mesage could be given. It took me a while to track it down, if suitable, if the error could indicate not to use
self.dismiss
incall_after_refresh
it might be useful.Sorry I cannot give clear versions on which this works / does not work. But it is OK in
0.71.0
but not in most recent version.