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

Method post_message

src/textual/widget.py:4486–4508  ·  view source on GitHub ↗

Post a message to this widget. Args: message: Message to post. Returns: True if the message was posted, False if this widget was closed / closing.

(self, message: Message)

Source from the content-addressed store, hash-verified

4484 await self.app.run_action(action, self, namespaces)
4485
4486 def post_message(self, message: Message) -> bool:
4487 """Post a message to this widget.
4488
4489 Args:
4490 message: Message to post.
4491
4492 Returns:
4493 True if the message was posted, False if this widget was closed / closing.
4494 """
4495 _rich_traceback_omit = True
4496 # Catch a common error.
4497 # This will error anyway, but at least we can offer a helpful message here.
4498 if not hasattr(message, "_prevent"):
4499 raise RuntimeError(
4500 f"{type(message)!r} is missing expected attributes; did you forget to call super().__init__() in the constructor?"
4501 )
4502
4503 if constants.DEBUG and not self.is_running and not message.no_dispatch:
4504 try:
4505 self.log.warning(self, f"IS NOT RUNNING, {message!r} not sent")
4506 except NoActiveAppError:
4507 pass
4508 return super().post_message(message)
4509
4510 async def on_prune(self, event: messages.Prune) -> None:
4511 """Close message loop when asked to prune."""

Callers 15

_forward_eventMethod · 0.95
_get_suggestionMethod · 0.45
resize_terminalMethod · 0.45
await_watcherFunction · 0.45
action_scroll_downMethod · 0.45
action_scroll_upMethod · 0.45
_on_mouse_moveMethod · 0.45
_on_clickMethod · 0.45
_on_mountMethod · 0.45
_select_or_commandMethod · 0.45
_stop_event_leakMethod · 0.45
_action_escapeMethod · 0.45

Calls 1

warningMethod · 0.45

Tested by

no test coverage detected