MCPcopy
hub / github.com/Textualize/textual / dismiss

Method dismiss

src/textual/screen.py:2048–2081  ·  view source on GitHub ↗

Dismiss the screen, optionally with a result. Any callback provided in [push_screen][textual.app.App.push_screen] will be invoked with the supplied result. !!! warning Textual will raise a [`ScreenError`][textual.app.ScreenError] if you await the return value from a

(self, result: ScreenResultType | None = None)

Source from the content-addressed store, hash-verified

2046 self.selections = selections
2047
2048 def dismiss(self, result: ScreenResultType | None = None) -> AwaitComplete:
2049 """Dismiss the screen, optionally with a result.
2050
2051 Any callback provided in [push_screen][textual.app.App.push_screen] will be invoked with the supplied result.
2052
2053 !!! warning
2054
2055 Textual will raise a [`ScreenError`][textual.app.ScreenError] if you await the return value from a
2056 message handler on the Screen being dismissed. If you want to dismiss the current screen, you can
2057 call `self.dismiss()` _without_ awaiting.
2058
2059 Args:
2060 result: The optional result to be passed to the result callback.
2061
2062 """
2063 _rich_traceback_omit = True
2064 if self._result_callbacks:
2065 callback = self._result_callbacks[-1]
2066 callback(result)
2067 await_pop = self.app.pop_screen()
2068
2069 def pre_await() -> None:
2070 """Called by the AwaitComplete object."""
2071 _rich_traceback_omit = True
2072 if active_message_pump.get() is self:
2073 from textual.app import ScreenError
2074
2075 raise ScreenError(
2076 "Can't await screen.dismiss() from the screen's message handler; try removing the await keyword."
2077 )
2078
2079 await_pop.set_pre_await_callback(pre_await)
2080
2081 return await_pop
2082
2083 def pop_until_active(self) -> None:
2084 """Pop any screens on top of this one, until this screen is active.

Callers 14

action_dismissMethod · 0.95
_on_clickMethod · 0.80
_select_or_commandMethod · 0.80
_action_escapeMethod · 0.80
pop_screensMethod · 0.80
on_button_pressedMethod · 0.80
action_quitMethod · 0.80
handle_okMethod · 0.80
key_pMethod · 0.80
on_button_pressedMethod · 0.80
on_button_pressedMethod · 0.80
handle_yesMethod · 0.80

Calls 3

pop_screenMethod · 0.80
callbackFunction · 0.50

Tested by 5

action_quitMethod · 0.64
handle_okMethod · 0.64
key_pMethod · 0.64
on_button_pressedMethod · 0.64
on_button_pressedMethod · 0.64