# libtmux.Window

- **Module:** libtmux
- **Package:** libtmux
- **Language:** Python
- **Kind:** class
- **Source:** https://github.com/tmux-python/libtmux/blob/9fdd083a8181a827889337b63cd4e6daea661a8c/src/libtmux/window.py#L54
- **Page:** https://libtmux.org/en/py/latest/reference/libtmux-window/

:term:`tmux(1)` :term:`Window` [window_manual]_.

Holds :class:`Pane` objects.

## Example

```python
>>> window = session.new_window('My project', attach=True)
```

## Example

```python
>>> window
Window(@2 2:My project, Session($... ...))
```

## Example

Windows have panes:

```python
>>> window.panes
[Pane(...)]
```

## Example

```python
>>> window.active_pane
Pane(...)
```

## Example

Relations moving up:

```python
>>> window.session
Session(...)
```

## Example

```python
>>> window.window_id == session.active_window.window_id
True
```

## Example

```python
>>> window == session.active_window
True
```

## Example

```python
>>> window in session.windows
True
```

## Example

The window can be used as a context manager to ensure proper cleanup:

```python
>>> with session.new_window() as window:
...     pane = window.split()
...     # Do work with the pane
...     # Window will be killed automatically when exiting the context
```

## Members

- `default_option_scope` (attribute)
- `default_hook_scope` (attribute)
- `server` (attribute)
- `__enter__` (method): Enter the context, returning self.
- `__exit__` (method): Exit the context, killing the window if it exists.
- `refresh` (method): Refresh window attributes from tmux.
- `from_window_id` (method): Create Window from existing window_id.
- `from_env` (method): Return the window containing the pane this process runs inside of.
- `session` (property): Parent session of window.
- `linked_sessions` (property): Every session this window is reachable from.
- `panes` (property): Panes contained by window.
- `search_panes` (method): Panes in this window, optionally filtered by tmux.
- `cmd` (method): Execute tmux subcommand within window context.
- `select_pane` (method): Select pane and return selected :class:`Pane`.
- `split` (method): Split window on active pane and return the created :class:`Pane`.
- `new_pane` (method): Create a floating :class:`Pane` in this window (``$ tmux new-pane``).
- `resize` (method): Resize tmux window.
- `last_pane` (method): Select the last (previously active) pane via ``$ tmux last-pane``.
- `select_layout` (method): Select layout for window.
- `next_layout` (method): Cycle to the next layout via ``$ tmux next-layout``.
- `previous_layout` (method): Cycle to the previous layout via ``$ tmux previous-layout``.
- `link` (method): Link this window to another session via ``$ tmux link-window``.
- `unlink` (method): Unlink this window from the current session via ``$ tmux unlink-window``.
- `rotate` (method): Rotate pane positions in the window via ``$ tmux rotate-window``.
- `respawn` (method): Respawn the window process via ``$ tmux respawn-window``.
- `swap` (method): Swap this window with another via ``$ tmux swap-window``.
- `display_message` (method): Display message at window scope via ``$ tmux display-message``.
- `rename_window` (method): Rename window.
- `kill` (method): Kill :class:`Window`.
- `move_window` (method): Move current :class:`Window` object ``$ tmux move-window``.
- `new_window` (method): Create new window respective of current window's position.
- `select` (method): Select window.
- `active_pane` (property): Return attached :class:`Pane`.
- `__eq__` (method): Equal operator for :class:`Window` object.
- `__repr__` (method): Representation of :class:`Window` object.
- `id` (property): Alias of :attr:`Window.window_id`.
- `name` (property): Alias of :attr:`Window.window_name`.
- `index` (property): Alias of :attr:`Window.window_index`.
- `height` (property): Alias of :attr:`Window.window_height`.
- `width` (property): Alias of :attr:`Window.window_width`.
- `split_window` (method): Split window and return the created :class:`Pane`.
- `attached_pane` (property): Return attached :class:`Pane`.
- `select_window` (method): Select window.
- `kill_window` (method): Kill the current :class:`Window` object. ``$ tmux kill-window``.
- `set_window_option` (method): Set option for tmux window. Deprecated by :meth:`Window.set_option()`.
- `show_window_options` (method): Show options for tmux window. Deprecated by :meth:`Window.show_options()`.
- `show_window_option` (method): Return option for target window. Deprecated by :meth:`Window.show_option()`.
- `get` (method): Return key-based lookup. Deprecated by attributes.
- `__getitem__` (method): Return item lookup by key. Deprecated in favor of attributes.
- `get_by_id` (method): Return pane by id. Deprecated in favor of :meth:`.panes.get()`.
- `where` (method): Filter through panes, return list of :class:`Pane`.
- `find_where` (method): Filter through panes, return first :class:`Pane`.
- `_list_panes` (method): Return list of panes (deprecated in favor of :meth:`.panes`).
- `_panes` (property): Property / alias to return :meth:`~._list_panes`.
- `list_panes` (method): Return list of :class:`Pane` for the window.
- `children` (property): Was used by TmuxRelationalObject (but that's longer used in this class).
- `active_window_index` (attribute)
- `alternate_saved_x` (attribute)
- `alternate_saved_y` (attribute)
- `bracket_paste_flag` (attribute)
- `buffer_name` (attribute)
- `buffer_sample` (attribute)
- `buffer_size` (attribute)
- `client_activity` (attribute)
- `client_cell_height` (attribute)
- `client_cell_width` (attribute)
- `client_control_mode` (attribute)
- `client_created` (attribute)
- `client_discarded` (attribute)
- `client_flags` (attribute)
- `client_height` (attribute)
- `client_key_table` (attribute)
- `client_last_session` (attribute)
- `client_mode_format` (attribute)
- `client_name` (attribute)
- `client_pid` (attribute)
- `client_prefix` (attribute)
- `client_readonly` (attribute)
- `client_session` (attribute)
- `client_termfeatures` (attribute)
- `client_termname` (attribute)
- `client_termtype` (attribute)
- `client_tty` (attribute)
- `client_uid` (attribute)
- `client_user` (attribute)
- `client_utf8` (attribute)
- `client_width` (attribute)
- `client_written` (attribute)
- `command_list_alias` (attribute)
- `command_list_name` (attribute)
- `command_list_usage` (attribute)
- `config_files` (attribute)
- `copy_cursor_line` (attribute)
- `copy_cursor_word` (attribute)
- `copy_cursor_x` (attribute)
- `copy_cursor_y` (attribute)
- `current_file` (attribute)
- `cursor_character` (attribute)
- `cursor_flag` (attribute)
- `cursor_x` (attribute)
- `cursor_y` (attribute)
- `history_bytes` (attribute)
- `history_limit` (attribute)
- `history_size` (attribute)
- `insert_flag` (attribute)
- `keypad_cursor_flag` (attribute)
- `keypad_flag` (attribute)
- `last_window_index` (attribute)
- `line` (attribute)
- `mouse_all_flag` (attribute)
- `mouse_any_flag` (attribute)
- `mouse_button_flag` (attribute)
- `mouse_sgr_flag` (attribute)
- `mouse_standard_flag` (attribute)
- `next_session_id` (attribute)
- `origin_flag` (attribute)
- `pane_active` (attribute)
- `pane_at_bottom` (attribute)
- `pane_at_left` (attribute)
- `pane_at_right` (attribute)
- `pane_at_top` (attribute)
- `pane_bg` (attribute)
- `pane_bottom` (attribute)
- `pane_current_command` (attribute)
- `pane_current_path` (attribute)
- `pane_dead` (attribute)
- `pane_dead_signal` (attribute)
- `pane_dead_status` (attribute)
- `pane_dead_time` (attribute)
- `pane_fg` (attribute)
- `pane_flags` (attribute)
- `pane_floating_flag` (attribute)
- `pane_format` (attribute)
- `pane_height` (attribute)
- `pane_id` (attribute)
- `pane_in_mode` (attribute)
- `pane_index` (attribute)
- `pane_input_off` (attribute)
- `pane_last` (attribute)
- `pane_left` (attribute)
- `pane_marked` (attribute)
- `pane_marked_set` (attribute)
- `pane_mode` (attribute)
- `pane_path` (attribute)
- `pane_pb_progress` (attribute)
- `pane_pb_state` (attribute)
- `pane_pid` (attribute)
- `pane_pipe` (attribute)
- `pane_pipe_pid` (attribute)
- `pane_right` (attribute)
- `pane_search_string` (attribute)
- `pane_start_command` (attribute)
- `pane_start_path` (attribute)
- `pane_synchronized` (attribute)
- `pane_tabs` (attribute)
- `pane_title` (attribute)
- `pane_top` (attribute)
- `pane_tty` (attribute)
- `pane_width` (attribute)
- `pane_x` (attribute)
- `pane_y` (attribute)
- `pane_z` (attribute)
- `pane_zoomed_flag` (attribute)
- `pid` (attribute)
- `scroll_position` (attribute)
- `scroll_region_lower` (attribute)
- `scroll_region_upper` (attribute)
- `search_match` (attribute)
- `selection_end_x` (attribute)
- `selection_end_y` (attribute)
- `selection_start_x` (attribute)
- `selection_start_y` (attribute)
- `session_activity` (attribute)
- `session_alerts` (attribute)
- `session_attached` (attribute)
- `session_attached_list` (attribute)
- `session_created` (attribute)
- `session_format` (attribute)
- `session_group` (attribute)
- `session_group_attached` (attribute)
- `session_group_attached_list` (attribute)
- `session_group_list` (attribute)
- `session_group_many_attached` (attribute)
- `session_group_size` (attribute)
- `session_grouped` (attribute)
- `session_id` (attribute)
- `session_last_attached` (attribute)
- `session_many_attached` (attribute)
- `session_marked` (attribute)
- `session_name` (attribute)
- `session_path` (attribute)
- `session_stack` (attribute)
- `session_windows` (attribute)
- `socket_path` (attribute)
- `start_time` (attribute)
- `synchronized_output_flag` (attribute)
- `uid` (attribute)
- `user` (attribute)
- `version` (attribute)
- `window_active` (attribute)
- `window_active_clients` (attribute)
- `window_active_clients_list` (attribute)
- `window_active_sessions` (attribute)
- `window_active_sessions_list` (attribute)
- `window_activity` (attribute)
- `window_activity_flag` (attribute)
- `window_bell_flag` (attribute)
- `window_bigger` (attribute)
- `window_cell_height` (attribute)
- `window_cell_width` (attribute)
- `window_end_flag` (attribute)
- `window_flags` (attribute)
- `window_format` (attribute)
- `window_height` (attribute)
- `window_id` (attribute)
- `window_index` (attribute)
- `window_last_flag` (attribute)
- `window_layout` (attribute)
- `window_linked` (attribute)
- `window_linked_sessions` (attribute)
- `window_linked_sessions_list` (attribute)
- `window_marked_flag` (attribute)
- `window_name` (attribute)
- `window_offset_x` (attribute)
- `window_offset_y` (attribute)
- `window_panes` (attribute)
- `window_raw_flags` (attribute)
- `window_silence_flag` (attribute)
- `window_stack_index` (attribute)
- `window_start_flag` (attribute)
- `window_visible_layout` (attribute)
- `window_width` (attribute)
- `window_zoomed_flag` (attribute)
- `wrap_flag` (attribute)
- `_refresh` (method): Refresh dataclass fields from a single ``list-*`` row.
- `__init__` (method): When not a user (custom) option, scope can be implied.
- `set_option` (method): Set option for tmux target.
- `unset_option` (method): Unset option for tmux target.
- `_show_options_raw` (method): Return a dict of options for the target.
- `_show_options_dict` (method): Return dict of options for the target.
- `_show_options` (method): Return a dict of options for the target.
- `show_options` (method): Return all options for the target.
- `_show_option_raw` (method): Return raw option output for target.
- `_show_option` (method): Return option value for the target.
- `show_option` (method): Return option value for the target.
- `hooks` (attribute)
- `_tmux_bin` (property): Resolve tmux_bin from self (Server) or self.server (Session/Window/Pane).
- `run_hook` (method): Run a hook immediately. Useful for testing.
- `set_hook` (method): Set hook for tmux target.
- `unset_hook` (method): Unset hook for tmux target.
- `show_hooks` (method): Return a dict of hooks for the target.
- `_show_hook` (method): Return value for the hook.
- `show_hook` (method): Return value for a hook.
- `set_hooks` (method): Set multiple indexed hooks at once.
