World > Camera > Docking#

Use world.camera.add_right(...), world.camera.add_left(...), world.camera.add_bottom(...), and world.camera.switch_world(...) as the public API for docking and switching helper worlds.

The class below is the internal helper that implements this behavior behind the public camera API.

API Reference#

class miniworlds.worlds.manager.layout_manager.LayoutManager(world, app)[source]#

LayoutManager handles the positioning and management of World objects within an application window.

It is stored internally on world._layout, while the public API is exposed via world.camera and delegates layout behavior to the underlying App and WorldsManager.

__init__(world, app)[source]#

Initialize a LayoutManager for a given world and application.

Parameters:
  • world – The World instance that owns this layout manager.

  • app – The application instance managing all worlds.

Example

>>> world.camera.add_right(Toolbar(), size=150)
add_bottom(world, size=100)[source]#

Adds a new world below the current world.

Return type:

World

Parameters:
  • world – The World instance to dock.

  • size – Height of the added world in pixels (default: 100).

Returns:

The newly added World instance.

Example

>>> world.camera.add_bottom(Console(), size=200)
add_left(world, size=100)[source]#

Adds a new world to the left side of the current world.

The current world (and all worlds docked to its right) are shifted to the right by the width of the added world.

Return type:

World

Parameters:
  • world – The World instance to dock.

  • size – Width of the added world in pixels (default: 100).

Returns:

The newly added World instance.

Example

>>> world.camera.add_left(Toolbar(), size=150)
add_right(world, size=100)[source]#

Adds a new world to the right side of the current world.

Return type:

World

Parameters:
  • world – The World instance to dock.

  • size – Width of the added world in pixels (default: 100).

Returns:

The newly added World instance.

Example

>>> world.camera.add_right(Toolbar(), size=150)
remove_world(world)[source]#

Removes a world from the current layout.

Return type:

None

Parameters:

world – The World instance to remove.

Example

>>> world.camera.remove_world(toolbar)
switch_world(new_world, reset=False)[source]#

Switches focus to another world.

Return type:

None

Parameters:
  • new_world – The World instance to activate.

  • reset – Whether to reset the world state (default: False).

Example

>>> world.camera.switch_world(main_scene, reset=True)
property window_docking_position: str | None#

Returns the docking position of this world in the window layout.

Returns:

A string such as “right” or “bottom”, or None if undocked.

Example

>>> world.camera.window_docking_position
'right'