# libtmux.Window.display_message

- **Module:** libtmux
- **Package:** libtmux
- **Language:** Python
- **Kind:** method
- **Source:** https://github.com/tmux-python/libtmux/blob/38e368c11117fb4aeb2f082d552cd4f210eae06a/src/libtmux/window.py#L1202
- **Page:** https://libtmux.org/en/py/stable/reference/libtmux-window-display_message/

```
libtmux.Window.display_message(
    self,
    cmd: str,
    get_text: t.Literal[True],
    format_string: str | None = ...,
    all_formats: bool | None = ...,
    verbose: bool | None = ...,
    no_expand: bool | None = ...,
    target_client: str | None = ...,
    delay: int | None = ...,
    notify: bool | None = ...,
) -> list[str]

libtmux.Window.display_message(
    self,
    cmd: str,
    get_text: t.Literal[False] = ...,
    format_string: str | None = ...,
    all_formats: bool | None = ...,
    verbose: bool | None = ...,
    no_expand: bool | None = ...,
    target_client: str | None = ...,
    delay: int | None = ...,
    notify: bool | None = ...,
) -> None

libtmux.Window.display_message(
    self,
    cmd: str,
    get_text: bool = False,
    format_string: str | None = None,
    all_formats: bool | None = None,
    verbose: bool | None = None,
    no_expand: bool | None = None,
    target_client: str | None = None,
    delay: int | None = None,
    notify: bool | None = None,
) -> list[str] | None
```

Display message at window scope via [`$ tmux display-message`](/en/tmux/latest/manual/display-message/).

Like :meth:`Pane.display_message` but auto-injects ``-t @<window-id>``
instead of a pane id. Window-scoped format reads such as
[`#{window_zoomed_flag}`](/en/tmux/latest/catalog/formats/window_zoomed_flag/) or [`#{window_active_clients}`](/en/tmux/latest/catalog/formats/window_active_clients/) no longer
require dropping to :meth:`Window.cmd`.

### Notes

Stderr from tmux is reported via :func:`warnings.warn`, not raised.
Callers that want to escalate to an exception can wrap the call in
:func:`warnings.catch_warnings` with ``filterwarnings("error")``.

## Examples

Read the window's id format:

```python
>>> result = window.display_message("#{window_id}", get_text=True)
>>> result[0].startswith("@")
True
```

Check zoom state (a common gap-#670 use case):

```python
>>> result = window.display_message(
...     "#{window_zoomed_flag}", get_text=True
... )
>>> result[0] in {"0", "1"}
True
```

## Changed

0.57 — Reports stderr via :func:`warnings.warn` instead of raising.

## Parameters

- `cmd` (`str`): Format string to display or evaluate (e.g.
``"#{window_zoomed_flag}"``). (added 0.57)
- `get_text` (`bool`): Return tmux's stdout instead of rendering to the status line
(``-p`` flag). (added 0.57)
- `format_string` (`str | None`): Alternative format template (``-F`` flag). (added 0.57)
- `all_formats` (`bool | None`): List all format variables (``-a`` flag). (added 0.57)
- `verbose` (`bool | None`): Show format variable types (``-v`` flag). (added 0.57)
- `no_expand` (`bool | None`): Output the literal string without format expansion (``-l`` flag).
Requires tmux 3.4+. (added 0.57)
- `target_client` (`str | None`): Target client (``-c`` flag). (added 0.57)
- `delay` (`int | None`): Display time in milliseconds (``-d`` flag). (added 0.57)
- `notify` (`bool | None`): Do not wait for input (``-N`` flag). (added 0.57)

## Returns

list[str] | None
    Message output if ``get_text`` is True, otherwise ``None``.

## In other ports

### Show a message on the client viewing a window

- Rust: [`window.Window.display`](/en/rs/latest/reference/window-window-display/) (method)
- Go: [`tmux.Window.DisplayMessage`](/en/go/latest/reference/tmux-window-displaymessage/) (method)
- C#: [`LibTmux.Window.DisplayMessageAsync`](/en/csharp/latest/reference/libtmux-window-displaymessageasync/) (method)
- C++: [`libtmux::Window::show_message`](/en/cxx/latest/reference/libtmux-window-show_message/) (method)
